Skip to content

Commit

Permalink
Update v3.71
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginder-Singh committed May 17, 2023
2 parents f47c9a9 + a79aa97 commit a577bd6
Show file tree
Hide file tree
Showing 45 changed files with 4,002 additions and 0 deletions.
53 changes: 53 additions & 0 deletions base/src/main/java/com/windscribe/vpn/api/CustomSocketFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.windscribe.vpn.api

import com.windscribe.vpn.Windscribe
import com.windscribe.vpn.apppreference.PreferencesHelper
import com.windscribe.vpn.backend.wireguard.WireguardBackend
import com.windscribe.vpn.exceptions.WindScribeException
import com.windscribe.vpn.localdatabase.LocalDbInterface
import com.windscribe.vpn.repository.LocationRepository
import com.windscribe.vpn.repository.UserRepository
import java.net.InetAddress
import java.net.InetSocketAddress
import java.net.Proxy
import java.net.Socket
import javax.inject.Singleton
import javax.net.SocketFactory
import kotlinx.coroutines.CoroutineScope
import org.slf4j.LoggerFactory

class CustomSocketFactory : SocketFactory() {
private var logger = LoggerFactory.getLogger("socket_factory")
override fun createSocket(): Socket {
val socket = Socket(Proxy.NO_PROXY)
try {
socket.bind(InetSocketAddress(0))
val activeBackend = Windscribe.appContext.vpnController.vpnBackendHolder.activeBackend
if (activeBackend is WireguardBackend && activeBackend.active) {
val protected = activeBackend.service?.protect(socket)
if(protected == false){
logger.debug("Failed to protect socket from wg tunnel")
}
}
} catch (e: Exception) {
logger.debug("Error creating socket: ${e.message}")
}
return socket
}

override fun createSocket(host: String?, port: Int): Socket {
throw WindScribeException("Not supported")
}

override fun createSocket(host: String?, port: Int, localHost: InetAddress?, localPort: Int): Socket {
throw WindScribeException("Not supported")
}

override fun createSocket(host: InetAddress?, port: Int): Socket {
throw WindScribeException("Not supported")
}

override fun createSocket(address: InetAddress?, port: Int, localAddress: InetAddress?, localPort: Int): Socket {
throw WindScribeException("Not supported")
}
}
Loading

0 comments on commit a577bd6

Please sign in to comment.