Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into use-exit-node-intent
Browse files Browse the repository at this point in the history
* upstream/main:
  android: bump version code (#152)
  Record DNS search domains as well as nameservers.
  cmd/tailscale: remove obsolete DNS config logging
  DnsConfig: get rid of unnecessary isEmpty check (#149)
  use network callback to update DNS config when network changes (#147)
  .gitignore: ignore IDE (#148)
  android: bump version code
  Update OSS 1.57.x.
  .gitignore: ignore Java profiling files (#146)
  build.gradle: increase JVM memory settings (#145)
  • Loading branch information
333fred committed Feb 5, 2024
2 parents afb5c3c + 813ca8a commit 794aa86
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 428 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ tailscale-fdroid.apk
tailscale.jks

# android sdk dir
./android-sdk
./android-sdk

# Java profiling output
*.hprof

#IDE
.vscode
Empty file added .vscode/settings.json
Empty file.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
defaultConfig {
minSdkVersion 22
targetSdkVersion 33
versionCode 192
versionName "1.55.148-t86aa0485a-g5ef7bbaff0a"
versionCode 195
versionName "1.57.100-t8250582fe-g4799cc1ef"
}
compileOptions {
sourceCompatibility 1.8
Expand Down
3 changes: 2 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
1 change: 1 addition & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

<!-- Disable input emulation on ChromeOS -->
<uses-feature android:name="android.hardware.type.pc" android:required="false"/>
Expand Down
50 changes: 30 additions & 20 deletions android/src/main/java/com/tailscale/ipn/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import org.gioui.Gio;

public class App extends Application {
private final static String PEER_TAG = "peer";
private static final String PEER_TAG = "peer";

static final String STATUS_CHANNEL_ID = "tailscale-status";
static final int STATUS_NOTIFICATION_ID = 1;
Expand All @@ -82,43 +82,53 @@ public class App extends Application {
private static final String FILE_CHANNEL_ID = "tailscale-files";
private static final int FILE_NOTIFICATION_ID = 3;

private final static Handler mainHandler = new Handler(Looper.getMainLooper());
private static final Handler mainHandler = new Handler(Looper.getMainLooper());

public DnsConfig dns = new DnsConfig(this);
private ConnectivityManager connectivityManager;
public DnsConfig dns = new DnsConfig();
public DnsConfig getDnsConfigObj() { return this.dns; }

@Override public void onCreate() {
super.onCreate();
// Load and initialize the Go library.
Gio.init(this);
registerNetworkCallback();

this.connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
setAndRegisterNetworkCallbacks();

createNotificationChannel(NOTIFY_CHANNEL_ID, "Notifications", NotificationManagerCompat.IMPORTANCE_DEFAULT);
createNotificationChannel(STATUS_CHANNEL_ID, "VPN Status", NotificationManagerCompat.IMPORTANCE_LOW);
createNotificationChannel(FILE_CHANNEL_ID, "File transfers", NotificationManagerCompat.IMPORTANCE_DEFAULT);

}

private void registerNetworkCallback() {
ConnectivityManager cMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
cMgr.registerNetworkCallback(new NetworkRequest.Builder().build(), new ConnectivityManager.NetworkCallback() {
private void reportConnectivityChange() {
NetworkInfo active = cMgr.getActiveNetworkInfo();
// https://developer.android.com/training/monitoring-device-state/connectivity-status-type
boolean isConnected = active != null && active.isConnectedOrConnecting();
onConnectivityChanged(isConnected);
// requestNetwork attempts to find the best network that matches the passed NetworkRequest. It is possible that
// this might return an unusuable network, eg a captive portal.
private void setAndRegisterNetworkCallbacks() {
connectivityManager.requestNetwork(dns.getDNSConfigNetworkRequest(), new ConnectivityManager.NetworkCallback(){
@Override
public void onAvailable(Network network){
super.onAvailable(network);
StringBuilder sb = new StringBuilder("");
LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
List<InetAddress> dnsList = linkProperties.getDnsServers();
for (InetAddress ip : dnsList) {
sb.append(ip.getHostAddress()).append(" ");
}
String searchDomains = linkProperties.getDomains();
if (searchDomains != null) {
sb.append("\n");
sb.append(searchDomains);
}

dns.updateDNSFromNetwork(sb.toString());
onDnsConfigChanged();
}

@Override
public void onLost(Network network) {
super.onLost(network);
this.reportConnectivityChange();
}

@Override
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
super.onLinkPropertiesChanged(network, linkProperties);
this.reportConnectivityChange();
onDnsConfigChanged();
}
});
}
Expand Down Expand Up @@ -347,7 +357,7 @@ public void createNotificationChannel(String id, String name, int importance) {
}

static native void onVPNPrepared();
private static native void onConnectivityChanged(boolean connected);
private static native void onDnsConfigChanged();
static native void onShareIntent(int nfiles, int[] types, String[] mimes, String[] items, String[] names, long[] sizes);
static native void onWriteStorageGranted();

Expand Down

0 comments on commit 794aa86

Please sign in to comment.