mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 01:07:10 +00:00
draft: Tun respond ICMP port unreachable when rejecting UDP packets
This commit is contained in:
@@ -33,6 +33,9 @@ type WriterWithUpstream = network.WriterWithUpstream
|
||||
type WithUpstreamWriter = network.WithUpstreamWriter
|
||||
type WithUpstream = common.WithUpstream
|
||||
|
||||
type HandshakeSuccess = network.HandshakeSuccess
|
||||
type HandshakeFailure = network.HandshakeFailure
|
||||
|
||||
var UnwrapReader = network.UnwrapReader
|
||||
var UnwrapWriter = network.UnwrapWriter
|
||||
|
||||
|
||||
31
common/utils/cast.go
Normal file
31
common/utils/cast.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
type WithUpstream interface {
|
||||
Upstream() any
|
||||
}
|
||||
|
||||
type stdWithUpstreamNetConn interface {
|
||||
NetConn() net.Conn
|
||||
}
|
||||
|
||||
func Cast[T any](obj any) (_ T, _ bool) {
|
||||
if c, ok := obj.(T); ok {
|
||||
fmt.Printf("Got 1: %T\n", obj) // TODO
|
||||
return c, true
|
||||
}
|
||||
if u, ok := obj.(WithUpstream); ok {
|
||||
fmt.Printf("Upstream 2: %T\n", obj) // TODO
|
||||
return Cast[T](u.Upstream())
|
||||
}
|
||||
if u, ok := obj.(stdWithUpstreamNetConn); ok {
|
||||
fmt.Printf("Std 3: %T\n", obj) // TODO
|
||||
return Cast[T](u.NetConn())
|
||||
}
|
||||
fmt.Printf("Failed: %T\n", obj) // TODO
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user