Repository navigation
cmd/tailscale: implement getInterfaces + SDK 30 - #21
Conversation
c01cc84 to
98c92da
Compare
| rcfg *router.Config | ||
| dcfg *dns.OSConfig | ||
| } | ||
| interfaces.RegisterInterfaceGetter(a.getInterfaces) |
There was a problem hiding this comment.
Can you try doing this line earlier in func main, before the goroutine to start runBackend?
I think it's fine here, but I can't convince myself there's not a race from something else.
c7efa63 to
5286bed
Compare
Signed-off-by: Denton Gentry <[email protected]>
5286bed to
7f8f14d
Compare
|
Tested on Android 6.0.1 and Android 12. |
| // v4-rmnet_data2 68 1472 true true false true true | 192.0.0.4/32 | ||
| // | ||
| // Where the fields are: | ||
| // name ifindex mtu isUp hasBroadcast isLoopback isPointToPoint hasMulticast | ip1/N,ip2/N,ip3/N; |
There was a problem hiding this comment.
stray semicolon at the end?
Oh! that's the separator, not a line delimiter.
How about remove the semicolon and just make every line end with a \n ?
Include the newline in the String iface and the join on the empty string instead?
There was a problem hiding this comment.
Done, used newline as line separator.
| return ""; | ||
| } | ||
|
|
||
| List<String> ifs = new ArrayList<String>(); |
There was a problem hiding this comment.
A java.lang.StringBuilder would be a bit less alloc heavy than all the String splitting and joining and formatting below.
But perhaps it doesn't matter at this point. We shouldn't call this super often? On Android it's currently every 10 minutes, or on link change notifications from the OS.
There was a problem hiding this comment.
Used StringBuilder.
| } | ||
| } | ||
|
|
||
| ifaces = append(ifaces, *newIf) |
There was a problem hiding this comment.
drop the * from this line and the & from line 1295?
| } | ||
|
|
||
| for _, iface := range strings.Split(ifaceString, ";") { | ||
| // Example of the strings we're processing: |
There was a problem hiding this comment.
If you go with newline-separated lines:
if strings.TrimSpace(line) == "" {
continue
}So you don't need to worry about the final empty element and still use Split here.
(strings.Split is generally not my friend, since it allocates, but this is no worse than the Java side's allocs, so it's fine for now.)
There was a problem hiding this comment.
Went with TrimSpace().
Java now uses a StringBuilder, we can revisit the Go code later.
| golang.zx2c4.com/wireguard v0.0.0-20210905140043-2ef39d47540c | ||
| inet.af/netaddr v0.0.0-20210721214506-ce7a8ad02cc1 | ||
| tailscale.com v1.1.1-0.20211005220235-67e5fabdbdba | ||
| tailscale.com v1.1.1-0.20211008004653-1f506d23514a |
There was a problem hiding this comment.
We used a release-branch for 1.14 in tailscale-android and it worked well.
Will update to 1.16.0 when release-branch/1.16 is created.
92c0865 to
9ec3d84
Compare
SDK 30 prohibits syscall.NetlinkRIB(syscall.RTM_GETADDR, ...) which Go's net.Interfaces uses. Implement an Android specific version of net.Interfaces to use instead. Passing primitive types across JNI is relatively straightforward, passing a single object of a complex class is annoying but still possible, but passing lists and other more complex data structures is way harder. As such, this commit added a Java routine to render the interface information to a string and pass that across JNI as a primitive type for Go code to parse. Fixes tailscale/tailscale#2293
9ec3d84 to
02a6ae0
Compare
|
I think this will work for 1.16.0, and lets us move to SDK 30. |
cmd/tailscale: implement getInterfaces + SDK 30
SDK 30 prohibits syscall.NetlinkRIB(syscall.RTM_GETADDR, ...) which Go's net.Interfaces uses. Implement an Android specific version of net.Interfaces to use instead.
Passing primitive types across JNI is relatively straightforward, passing a single object of a complex class is annoying but still possible, but passing lists and other more complex data structures is way harder. As such, this commit added a Java routine to render the interface information to a string and pass that across JNI as a primitive type for Go code to parse.
Fixes tailscale/tailscale#2293