From 8dfa8417114fdae142e8d019799e622e40e3b2e0 Mon Sep 17 00:00:00 2001 From: Mingye Chen Date: Thu, 27 Jul 2023 01:18:32 +0400 Subject: [PATCH] Fix DTLS logger (#205) * Unexport dialer * Deprecate decoy dialer * Split client transport interface * Add functions to interface * Remove delay from registrars * Add client side transport * Add transport to defaultTransport, fix client * Type alias instead of definition * Fix more type alias * Add station side transport * Sync gotapdance * Fix lint * Split client listen and dial * Add debug print * Revert "Add debug print" This reverts commit f5a162dec7a6000f2920e45fd22e6f3016c27792. * Fix err check * Increase heartbeat interval, rm print * Add SkipVerifyHello option skip hello verify when acting as server * Add connecting stats interface * Add connecting stats to regmanager * Add stats during handle connecting tp reg * Rename * Add discard * Implement connecting stats * Decrement stats * Add string, reset * Add connectingstats to regconfig * Load atomic * Print counts in stats * Fix comment * Dbg increase verbose * Rename vars * Change back verbose * Log unreg dtls part * Increase timeout * Revert "Increase timeout" This reverts commit 909f7e6e967bbedd0d9822cde66f9b76b8987b9e. * Implement custom listener * Add no registration num * Add examples * Add other failed state * Rm discard state * Rm more, add end state percentage * Rename timeout, check error * Print total end states * Split success states for connecting transport * Update client dep * Fix logger * Rm print --- pkg/transports/connecting/dtls/dnat.go | 4 ---- pkg/transports/connecting/dtls/dtls.go | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/transports/connecting/dtls/dnat.go b/pkg/transports/connecting/dtls/dnat.go index a08770b7..9f789d50 100644 --- a/pkg/transports/connecting/dtls/dnat.go +++ b/pkg/transports/connecting/dtls/dnat.go @@ -47,19 +47,15 @@ func newDNAT() (*dnat, error) { flags := IFF_TUN | IFF_NO_PI binary.LittleEndian.PutUint16(ifreq[0x10:], uint16(flags)) - fmt.Printf("fd: %v\n", tun.Fd()) _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, tun.Fd(), uintptr(TUNSETIFF), uintptr(unsafe.Pointer(&ifreq[0]))) if errno != 0 { tun.Close() return nil, errno } - fmt.Printf("fd after tun: %v\n", tun.Fd()) // Get the interface name name := string(ifreq[:bytes.IndexByte(ifreq[:], 0)]) - fmt.Println("Interface Name:", name) - // Bring the interface up err = setUp(tun, name) if err != nil { diff --git a/pkg/transports/connecting/dtls/dtls.go b/pkg/transports/connecting/dtls/dtls.go index 43d40ed5..e856b1ea 100644 --- a/pkg/transports/connecting/dtls/dtls.go +++ b/pkg/transports/connecting/dtls/dtls.go @@ -20,7 +20,6 @@ const listenPort = 41245 type Transport struct { dnat *dnat dtlsListener *dtls.Listener - unregLogger func(*net.IP) logDialSuccess func(*net.IP) logListenSuccess func(*net.IP) } @@ -56,9 +55,10 @@ func NewTransport(logAuthFail func(*net.IP), logOtherFail func(*net.IP), logDial } return &Transport{ - dnat: dnat, - dtlsListener: listener, - unregLogger: logAuthFail, + dnat: dnat, + dtlsListener: listener, + logDialSuccess: logDialSuccess, + logListenSuccess: logListenSuccess, }, nil }