WIP: prepare for testing

This commit is contained in:
2025-04-21 07:11:02 +10:00
parent df828e2e9e
commit 59a91d29fd
11 changed files with 66 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ package config
import (
"fmt"
"gitea.suyono.dev/suyono/netbounce/abstract"
)
@@ -59,5 +60,5 @@ func (t tcpModule) AsTCP() abstract.TCPConnectionConfig {
func (t tcpModule) AsUDP() abstract.UDPConnectionConfig {
panic(fmt.Errorf("not UDP"))
return nil
// return nil
}

View File

@@ -18,8 +18,10 @@ package config
import (
"fmt"
"gitea.suyono.dev/suyono/netbounce/abstract"
"net"
"time"
"gitea.suyono.dev/suyono/netbounce/abstract"
)
type udpConfig struct {
@@ -30,6 +32,10 @@ type udpConfig struct {
Timeout time.Duration `mapstructure:"timeout,30m"`
}
type udpBackendAddr struct {
config udpConfig
}
type udpModule struct {
config udpConfig
}
@@ -40,7 +46,7 @@ func (u udpModule) AsUDP() abstract.UDPConnectionConfig {
func (u udpModule) AsTCP() abstract.TCPConnectionConfig {
panic(fmt.Errorf("not UDP"))
return nil
// return nil
}
func (u udpModule) Name() string {
@@ -62,3 +68,15 @@ func (u udpModule) Backend() string {
func (u udpModule) Timeout() time.Duration {
return u.config.Timeout
}
func (u udpModule) BackendAddr() net.Addr {
return udpBackendAddr(u)
}
func (a udpBackendAddr) Network() string {
return "udp"
}
func (a udpBackendAddr) String() string {
return a.config.Backend
}