feature: MITM
This commit is contained in:
@ -30,6 +30,7 @@ var (
|
||||
udpQueue = make(chan C.PacketAdapter, 200)
|
||||
natTable = nat.New()
|
||||
rules []C.Rule
|
||||
rewrites C.RewriteRule
|
||||
listeners = make(map[string]C.InboundListener)
|
||||
subRules map[string][]C.Rule
|
||||
proxies = make(map[string]C.Proxy)
|
||||
@ -179,6 +180,18 @@ func isHandle(t C.Type) bool {
|
||||
return status == Running || (status == Inner && t == C.INNER)
|
||||
}
|
||||
|
||||
// Rewrites return all rewrites
|
||||
func Rewrites() C.RewriteRule {
|
||||
return rewrites
|
||||
}
|
||||
|
||||
// UpdateRewrites handle update rewrites
|
||||
func UpdateRewrites(rules C.RewriteRule) {
|
||||
configMux.Lock()
|
||||
rewrites = rules
|
||||
configMux.Unlock()
|
||||
}
|
||||
|
||||
// processUDP starts a loop to handle udp packet
|
||||
func processUDP() {
|
||||
queue := udpQueue
|
||||
@ -433,8 +446,9 @@ func handleTCPConn(connCtx C.ConnContext) {
|
||||
return
|
||||
}
|
||||
|
||||
isMitmProxy := metadata.Type == C.MITM
|
||||
dialMetadata := metadata
|
||||
if len(metadata.Host) > 0 {
|
||||
if len(metadata.Host) > 0 && !isMitmProxy {
|
||||
if node, ok := resolver.DefaultHosts.Search(metadata.Host, false); ok {
|
||||
if dstIp, _ := node.RandIP(); !FakeIPRange().Contains(dstIp) {
|
||||
dialMetadata.DstIP = dstIp
|
||||
|
Reference in New Issue
Block a user