2024-12-17 17:39:10 -05:00
|
|
|
package tunnelbroker
|
|
|
|
|
|
|
|
import (
|
|
|
|
`encoding/xml`
|
|
|
|
`net`
|
|
|
|
`net/netip`
|
|
|
|
|
|
|
|
`github.com/go-resty/resty/v2`
|
|
|
|
`r00t2.io/gobroke/conf`
|
|
|
|
)
|
|
|
|
|
2024-12-20 01:29:56 -05:00
|
|
|
/*
|
|
|
|
TunPrefix is derived from netip.Prefix.
|
|
|
|
Because even though -- EVEN THOUGH -- it has a TextMarshaler and TextUnmarshaler interface,
|
|
|
|
it fails to work properly because Golang.
|
|
|
|
https://github.com/jmoiron/sqlx/issues/957
|
|
|
|
*/
|
|
|
|
type TunPrefix netip.Prefix
|
2024-12-17 17:39:10 -05:00
|
|
|
|
|
|
|
type TunnelList struct {
|
|
|
|
XMLName xml.Name `json:"-" xml:"tunnels" yaml:"-"`
|
|
|
|
Tunnels []*Tunnel `json:"tunnels" xml:"tunnel" yaml:"Tunnels"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Tunnel struct {
|
2024-12-20 01:29:56 -05:00
|
|
|
XMLName xml.Name `json:"-" xml:"tunnel" yaml:"-"`
|
|
|
|
ID uint `json:"id" xml:"id,attr" yaml:"ID" db:"tun_id"`
|
|
|
|
Description string `json:"desc" xml:"description" yaml:"Description" db:"desc"`
|
|
|
|
ServerIPv4 net.IP `json:"tgt_v4" xml:"serverv4" yaml:"IPv4 Tunnel Target" db:"server_v4"`
|
|
|
|
ClientIPv4 net.IP `json:"client_v4" xml:"clientv4" yaml:"Configured IPv4 Client Address" db:"current_client_v4"`
|
|
|
|
ServerIPv6 net.IP `json:"server_v6" xml:"serverv6" yaml:"IPv6 Endpoint" db:"tunnel_server_v6"`
|
|
|
|
ClientIPv6 net.IP `json:"client_v6" xml:"clientv6" yaml:"IPv6 Tunnel Client Address" db:"tunnel_client_v6"`
|
|
|
|
Routed64 TunPrefix `json:"routed_64" xml:"routed64" yaml:"Routed /64" db:"prefix_64"`
|
|
|
|
Routed48 *TunPrefix `json:"routed_48,omitempty" xml:"routed48,omitempty" yaml:"Routed /48,omitempty" db:"prefix_48"`
|
|
|
|
RDNS1 *string `json:"rdns_1,omitempty" xml:"rdns1,omitempty" yaml:"RDNS #1,omitempty" db:"rdns_1"`
|
|
|
|
RDNS2 *string `json:"rdns_2,omitempty" xml:"rdns2,omitempty" yaml:"RDNS #2,omitempty" db:"rdns_2"`
|
|
|
|
RDNS3 *string `json:"rdns_3,omitempty" xml:"rdns3,omitempty" yaml:"RDNS #3,omitempty" db:"rdns_3"`
|
|
|
|
RDNS4 *string `json:"rdns_4,omitempty" xml:"rdns4,omitempty" yaml:"RDNS #4,omitempty" db:"rdns_4"`
|
|
|
|
RDNS5 *string `json:"rdns_5,omitempty" xml:"rdns5,omitempty" yaml:"RDNS #5,omitempty" db:"rdns_5"`
|
2024-12-17 17:39:10 -05:00
|
|
|
tunCfg *conf.Tunnel
|
2024-12-20 01:29:56 -05:00
|
|
|
client *resty.Client
|
2024-12-17 17:39:10 -05:00
|
|
|
}
|
|
|
|
|
2024-12-20 01:29:56 -05:00
|
|
|
type HTTPError struct {
|
|
|
|
Code int `json:"code" xml:"code,attr" yaml:"Status Code"`
|
|
|
|
CodeStr string `json:"code_str" xml:"code_str,attr" yaml:"Status Code (Detailed)"`
|
|
|
|
Message *string `json:"message,omitempty" xml:",chardata" yaml:"Error Message,omitempty"`
|
|
|
|
Resp *resty.Response `json:"-" xml:"-" yaml:"-"`
|
2024-12-17 17:39:10 -05:00
|
|
|
}
|