feat: initial commit

This commit is contained in:
2024-07-30 14:28:39 +02:00
commit 4729c54076
39 changed files with 3850 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package socketio
import (
"net"
"strconv"
"strings"
gosocketio "forge.cadoles.com/Pyxis/golang-socketio"
"github.com/pkg/errors"
)
func EndpointFromHAddr(addr string) (string, error) {
host, rawPort, err := net.SplitHostPort(addr)
if err != nil {
var addrErr *net.AddrError
if !errors.As(err, &addrErr) || !strings.Contains(addrErr.Error(), "missing port in address") {
return "", errors.WithStack(err)
}
host = addr
}
port := int64(80)
if rawPort != "" {
port, err = strconv.ParseInt(rawPort, 10, 32)
if err != nil {
return "", errors.WithStack(err)
}
}
endpoint := Endpoint(host, int(port), false)
return endpoint, nil
}
func Endpoint(host string, port int, secure bool) string {
return gosocketio.GetUrl(host, port, false)
}