openvpn connection status fix
This commit is contained in:
parent
28ae7eeaee
commit
6a9cc9bf37
1 changed files with 78 additions and 80 deletions
|
|
@ -28,25 +28,18 @@ import net.openvpn.ovpn3.ClientAPI_TransportStats
|
|||
|
||||
class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runnable {
|
||||
private val tag = "OpenVPNThreadv3"
|
||||
private var mConfig: JSONObject? = null
|
||||
private var mAlreadyInitialised = false
|
||||
private var mService: VPNService = service
|
||||
|
||||
override fun run() {
|
||||
//TEMP
|
||||
|
||||
val config: ClientAPI_Config = ClientAPI_Config()
|
||||
config.content = mService.getVpnConfig().getString("openvpn_config_data")
|
||||
|
||||
eval_config(config)
|
||||
val status = connect()
|
||||
Log.i(tag, "ERROR " + status)
|
||||
if (status.getError() != false) {
|
||||
if (status.getError()) {
|
||||
Log.i(tag, "connect() error: " + status.getError() + ": " + status.getMessage())
|
||||
mService.openvpnConnected()
|
||||
} else {
|
||||
Log.i(tag, "Connect succesfully, OpenVPN3 thread finished")
|
||||
mService.openvpnConnected()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,8 +47,13 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna
|
|||
Log.i(tag, arg0.getText())
|
||||
}
|
||||
|
||||
override fun event(event: ClientAPI_Event ){
|
||||
Log.i(tag, event.getName())
|
||||
override fun event(event: ClientAPI_Event ) {
|
||||
val eventName = event.getName()
|
||||
when (eventName) {
|
||||
"CONNECTED" -> mService.isUp = true
|
||||
"DISCONNECTED" -> mService.isUp = false
|
||||
}
|
||||
Log.i(tag, eventName)
|
||||
}
|
||||
|
||||
override fun tun_builder_new(): Boolean {
|
||||
|
|
@ -120,4 +118,4 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna
|
|||
override fun stop() {
|
||||
super.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue