Skip to content

Commit a577bd6

Browse files
committed
Update v3.71
2 parents f47c9a9 + a79aa97 commit a577bd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4002
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.windscribe.vpn.api
2+
3+
import com.windscribe.vpn.Windscribe
4+
import com.windscribe.vpn.apppreference.PreferencesHelper
5+
import com.windscribe.vpn.backend.wireguard.WireguardBackend
6+
import com.windscribe.vpn.exceptions.WindScribeException
7+
import com.windscribe.vpn.localdatabase.LocalDbInterface
8+
import com.windscribe.vpn.repository.LocationRepository
9+
import com.windscribe.vpn.repository.UserRepository
10+
import java.net.InetAddress
11+
import java.net.InetSocketAddress
12+
import java.net.Proxy
13+
import java.net.Socket
14+
import javax.inject.Singleton
15+
import javax.net.SocketFactory
16+
import kotlinx.coroutines.CoroutineScope
17+
import org.slf4j.LoggerFactory
18+
19+
class CustomSocketFactory : SocketFactory() {
20+
private var logger = LoggerFactory.getLogger("socket_factory")
21+
override fun createSocket(): Socket {
22+
val socket = Socket(Proxy.NO_PROXY)
23+
try {
24+
socket.bind(InetSocketAddress(0))
25+
val activeBackend = Windscribe.appContext.vpnController.vpnBackendHolder.activeBackend
26+
if (activeBackend is WireguardBackend && activeBackend.active) {
27+
val protected = activeBackend.service?.protect(socket)
28+
if(protected == false){
29+
logger.debug("Failed to protect socket from wg tunnel")
30+
}
31+
}
32+
} catch (e: Exception) {
33+
logger.debug("Error creating socket: ${e.message}")
34+
}
35+
return socket
36+
}
37+
38+
override fun createSocket(host: String?, port: Int): Socket {
39+
throw WindScribeException("Not supported")
40+
}
41+
42+
override fun createSocket(host: String?, port: Int, localHost: InetAddress?, localPort: Int): Socket {
43+
throw WindScribeException("Not supported")
44+
}
45+
46+
override fun createSocket(host: InetAddress?, port: Int): Socket {
47+
throw WindScribeException("Not supported")
48+
}
49+
50+
override fun createSocket(address: InetAddress?, port: Int, localAddress: InetAddress?, localPort: Int): Socket {
51+
throw WindScribeException("Not supported")
52+
}
53+
}

0 commit comments

Comments
 (0)