enhanced to http server to distinguish between ipv4 and ipv6 address when the ip address part is explicitly specified before colon port (e.g. 0.0.0.0:9999, [::]:9999, :9999)

This commit is contained in:
2024-12-07 23:03:23 +09:00
parent 8821506fb1
commit c81e05b4a3
4 changed files with 44 additions and 9 deletions

14
hodu.go
View File

@ -25,3 +25,17 @@ type Service interface {
WriteLog(id string, level LogLevel, fmtstr string, args ...interface{})
}
func tcp_addr_str_class(addr string) string {
if len(addr) > 0 {
switch addr[0] {
case '[':
return "tcp6"
case ':':
return "tcp"
default:
return "tcp4"
}
}
return "tcp"
}