-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ru lang to android app, fix disconnect in android app #169
base: master
Are you sure you want to change the base?
Changes from 1 commit
164e14b
b61cf02
2d3521a
1dbcc3b
5d14e1f
6cb3a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ public class GnirehtetService extends VpnService { | |
// magic value: higher (like 0x8000 or 0xffff) or lower (like 1500) values show poorer performances | ||
private static final int MTU = 0x4000; | ||
|
||
|
||
private final Notifier notifier = new Notifier(this); | ||
private final Handler handler = new RelayTunnelConnectionStateHandler(this); | ||
|
||
|
@@ -109,6 +110,19 @@ private void startVpn(VpnConfiguration config) { | |
} | ||
} | ||
|
||
@Override | ||
public void onRevoke() { | ||
try { | ||
forwarder.stop(); | ||
forwarder = null; | ||
vpnInterface.close(); | ||
vpnInterface = null; | ||
} catch (IOException e) { | ||
Log.w(TAG, "Cannot close VPN file descriptor", e); | ||
} | ||
stopSelf(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be possible to just call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stopSelf() - method from android api, iron destroy service. |
||
|
||
@SuppressWarnings("checkstyle:MagicNumber") | ||
private boolean setupVpn(VpnConfiguration config) { | ||
Builder builder = new Builder(); | ||
|
@@ -189,9 +203,7 @@ private void close() { | |
// already closed | ||
return; | ||
} | ||
|
||
notifier.stop(); | ||
|
||
notifier.removeFailure(); | ||
try { | ||
forwarder.stop(); | ||
forwarder = null; | ||
|
@@ -200,9 +212,8 @@ private void close() { | |
} catch (IOException e) { | ||
Log.w(TAG, "Cannot close VPN file descriptor", e); | ||
} | ||
stopSelf(); | ||
} | ||
|
||
|
||
private static final class RelayTunnelConnectionStateHandler extends Handler { | ||
|
||
private final GnirehtetService vpnService; | ||
|
@@ -220,11 +231,11 @@ public void handleMessage(Message message) { | |
switch (message.what) { | ||
case RelayTunnelListener.MSG_RELAY_TUNNEL_CONNECTED: | ||
Log.d(TAG, "Relay tunnel connected"); | ||
vpnService.notifier.setFailure(false); | ||
vpnService.notifier.setFailure(); | ||
break; | ||
case RelayTunnelListener.MSG_RELAY_TUNNEL_DISCONNECTED: | ||
Log.d(TAG, "Relay tunnel disconnected"); | ||
vpnService.notifier.setFailure(true); | ||
vpnService.notifier.removeFailure(); | ||
break; | ||
default: | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="relay_connected">Reverse tethering activé</string> | ||
<string name="relay_disconnected">Déconnecté du serveur relais</string> | ||
<string name="stop_vpn">Arrêter Gnirehtet</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="relay_connected">Подключение через Gnirehtet активно</string> | ||
<string name="stop_vpn">Остановить Gnirehtet</string> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
<resources> | ||
<string name="app_name" translatable="false">Gnirehtet</string> | ||
<string name="relay_connected">Reverse tethering enabled</string> | ||
<string name="relay_disconnected">Disconnected from the relay server</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like the close-on-disconnect behavior in addition to the current behavior (via a command-line option). See #51 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, dude dont find this thread. Think, when device disconnected from relay server, out service and notif only angry users (my users). Notif can not close. Sorry my english, bro, i from russian, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can work on this option when I have some time, if you prefer. |
||
<string name="stop_vpn">Stop Gnirehtet</string> | ||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it should rely on whether the socket is connected or not, whatever the USB state is (the socket can be disconnected while the USB cable is still connected).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, i not replace intent "ACTION_GNIREHTET_STOP"("socket can be disconnected while the USB cable is still connected"), i add intent USB_STATE with disconnected (if cabel unplug, then socket dont work too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not rely on USB state, but on the socket connection state.