mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-11 19:50:19 +08:00
cleanup fakedns package
This commit is contained in:
@@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/xjasonlyu/tun2socks/proxy"
|
"github.com/xjasonlyu/tun2socks/proxy"
|
||||||
"github.com/xjasonlyu/tun2socks/tun"
|
"github.com/xjasonlyu/tun2socks/tun"
|
||||||
|
|
||||||
D "github.com/xjasonlyu/tun2socks/component/dns"
|
D "github.com/xjasonlyu/tun2socks/component/fakedns"
|
||||||
S "github.com/xjasonlyu/tun2socks/component/stats"
|
S "github.com/xjasonlyu/tun2socks/component/stats"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/component/dns/fakedns"
|
"github.com/xjasonlyu/tun2socks/component/fakedns"
|
||||||
"github.com/xjasonlyu/tun2socks/log"
|
"github.com/xjasonlyu/tun2socks/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
package dns
|
package fakedns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
type FakeDNS interface {
|
type FakeDNS interface {
|
||||||
Start() error
|
Start() error
|
||||||
Stop() error
|
Stop() error
|
||||||
|
|
||||||
// IPToHost returns the corresponding domain for the given IP.
|
// IPToHost returns the corresponding domain for the given IP.
|
||||||
IPToHost(ip net.IP) (string, bool)
|
IPToHost(ip net.IP) (string, bool)
|
||||||
}
|
}
|
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/common/lsof"
|
"github.com/xjasonlyu/tun2socks/common/lsof"
|
||||||
"github.com/xjasonlyu/tun2socks/common/pool"
|
"github.com/xjasonlyu/tun2socks/common/pool"
|
||||||
"github.com/xjasonlyu/tun2socks/component/dns"
|
D "github.com/xjasonlyu/tun2socks/component/fakedns"
|
||||||
"github.com/xjasonlyu/tun2socks/component/stats"
|
"github.com/xjasonlyu/tun2socks/component/stats"
|
||||||
C "github.com/xjasonlyu/tun2socks/constant"
|
C "github.com/xjasonlyu/tun2socks/constant"
|
||||||
"github.com/xjasonlyu/tun2socks/core"
|
"github.com/xjasonlyu/tun2socks/core"
|
||||||
@@ -20,11 +20,11 @@ type tcpHandler struct {
|
|||||||
proxyHost string
|
proxyHost string
|
||||||
proxyPort int
|
proxyPort int
|
||||||
|
|
||||||
fakeDNS dns.FakeDNS
|
fakeDNS D.FakeDNS
|
||||||
sessionStater stats.SessionStater
|
sessionStater stats.SessionStater
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTCPHandler(proxyHost string, proxyPort int, fakeDNS dns.FakeDNS, sessionStater stats.SessionStater) core.TCPConnHandler {
|
func NewTCPHandler(proxyHost string, proxyPort int, fakeDNS D.FakeDNS, sessionStater stats.SessionStater) core.TCPConnHandler {
|
||||||
return &tcpHandler{
|
return &tcpHandler{
|
||||||
proxyHost: proxyHost,
|
proxyHost: proxyHost,
|
||||||
proxyPort: proxyPort,
|
proxyPort: proxyPort,
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/common/lsof"
|
"github.com/xjasonlyu/tun2socks/common/lsof"
|
||||||
"github.com/xjasonlyu/tun2socks/common/pool"
|
"github.com/xjasonlyu/tun2socks/common/pool"
|
||||||
"github.com/xjasonlyu/tun2socks/component/dns"
|
D "github.com/xjasonlyu/tun2socks/component/fakedns"
|
||||||
"github.com/xjasonlyu/tun2socks/component/stats"
|
"github.com/xjasonlyu/tun2socks/component/stats"
|
||||||
C "github.com/xjasonlyu/tun2socks/constant"
|
C "github.com/xjasonlyu/tun2socks/constant"
|
||||||
"github.com/xjasonlyu/tun2socks/core"
|
"github.com/xjasonlyu/tun2socks/core"
|
||||||
@@ -24,11 +24,11 @@ type udpHandler struct {
|
|||||||
remoteAddrMap sync.Map
|
remoteAddrMap sync.Map
|
||||||
remoteConnMap sync.Map
|
remoteConnMap sync.Map
|
||||||
|
|
||||||
fakeDNS dns.FakeDNS
|
fakeDNS D.FakeDNS
|
||||||
sessionStater stats.SessionStater
|
sessionStater stats.SessionStater
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUDPHandler(proxyHost string, proxyPort int, timeout time.Duration, fakeDNS dns.FakeDNS, sessionStater stats.SessionStater) core.UDPConnHandler {
|
func NewUDPHandler(proxyHost string, proxyPort int, timeout time.Duration, fakeDNS D.FakeDNS, sessionStater stats.SessionStater) core.UDPConnHandler {
|
||||||
return &udpHandler{
|
return &udpHandler{
|
||||||
proxyHost: proxyHost,
|
proxyHost: proxyHost,
|
||||||
proxyPort: proxyPort,
|
proxyPort: proxyPort,
|
||||||
|
@@ -8,12 +8,12 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xjasonlyu/tun2socks/component/dns"
|
D "github.com/xjasonlyu/tun2socks/component/fakedns"
|
||||||
"github.com/xjasonlyu/tun2socks/proxy/socks"
|
"github.com/xjasonlyu/tun2socks/proxy/socks"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DNS lookup
|
// DNS lookup
|
||||||
func lookupHost(fakeDNS dns.FakeDNS, target net.Addr) (targetHost string, err error) {
|
func lookupHost(fakeDNS D.FakeDNS, target net.Addr) (targetHost string, err error) {
|
||||||
var targetIP net.IP
|
var targetIP net.IP
|
||||||
switch addr := target.(type) {
|
switch addr := target.(type) {
|
||||||
case *net.TCPAddr:
|
case *net.TCPAddr:
|
||||||
|
Reference in New Issue
Block a user