Documentation ¶
Index ¶
- Constants
- Variables
- func DidError(w http.ResponseWriter, errCode int, err error) bool
- func GetRemoteIP(r *http.Request) string
- func InitializeLogger() (*zap.Logger, func() error)
- func MakeHTTPSRedirectHandler(dstPort string) func(w http.ResponseWriter, r *http.Request)
- func ShittyPack(s string) string
- func StartHTTPToHTTPSRedirector(ctx context.Context, httpBindAddr, targetAddr string, timeout time.Duration) error
- type QuicChecker
- type Req
- type Resp
- type Service
- func (svc *Service) CheckQuic(req *Req) *Resp
- func (svc *Service) CheckTCP(req *Req) *Resp
- func (svc *Service) CheckUDP(req *Req) *Resp
- func (svc *Service) Cleanup()
- func (svc *Service) Execute(req *Req) (*Resp, error)
- func (svc *Service) Home(w http.ResponseWriter, r *http.Request)
- func (svc *Service) ListenAndServe(ctx context.Context) error
- func (svc *Service) LoadHomePage() error
- func (svc *Service) Routes() *mux.Router
- func (svc *Service) UUpHandler(w http.ResponseWriter, r *http.Request)
- type ServiceOpt
- type UDPChecker
- type Waiter
- type WaiterMap
Constants ¶
View Source
const ( ProtoUDP = iota ProtoTCP ProtoHTTP ProtoHTTPS ProtoQuic )
View Source
const DefaultMaxDialTime = time.Second * 10
Variables ¶
View Source
var ( ErrEmptyInput = errors.New("user input empty") ErrMissingProto = errors.New("missing proto in uri") ErrMissingHost = errors.New("missing host in uri") ErrMissingPort = errors.New("missing port in uri") ErrInvalidFormat = errors.New("user input invalid") )
It's best to leak as little from golang's errors as possible. Thus, these errors are sent to the user for bad inputs.
View Source
var ErrProtocolNotHandled = errors.New("protocol not handled")
View Source
var InternalErrorJson = []byte(`{"err": "internal error"}`)
View Source
var ProtoMap = map[string]int{ "UDP": ProtoUDP, "TCP": ProtoTCP, "HTTP": ProtoHTTP, "HTTPS": ProtoHTTPS, "QUIC": ProtoQuic, }
Functions ¶
func GetRemoteIP ¶
TODO: This s not robust.
Need X-Forwarded-For support, which has security concerns.
func InitializeLogger ¶
func MakeHTTPSRedirectHandler ¶
func MakeHTTPSRedirectHandler(dstPort string) func(w http.ResponseWriter, r *http.Request)
func ShittyPack ¶
func StartHTTPToHTTPSRedirector ¶
func StartHTTPToHTTPSRedirector(ctx context.Context, httpBindAddr, targetAddr string, timeout time.Duration) error
Starts a HTTP to HTTPS redirector service on bindAddr.
- The server times out reads and writes longer than timeout. - The targetAddr should refer to the https address. - Cancelling the context shuts down the redirector.
Types ¶
type QuicChecker ¶
type QuicChecker struct {
// contains filtered or unexported fields
}
func NewQuicChecker ¶
func NewQuicChecker(bindAddr string, maxHandhake time.Duration) (*QuicChecker, error)
Create a new QuicChecker service.
This does not do any certificate validation.
type Service ¶
func New ¶
func New(opts ...ServiceOpt) (*Service, error)
func (*Service) LoadHomePage ¶
func (*Service) UUpHandler ¶
func (svc *Service) UUpHandler(w http.ResponseWriter, r *http.Request)
type ServiceOpt ¶
func DisableTCP ¶
func DisableTCP() ServiceOpt
func WithQuicService ¶
func WithQuicService(bindAddr string, maxDialTime time.Duration) ServiceOpt
func WithRouter ¶
func WithRouter(r *mux.Router) ServiceOpt
func WithUDPChecker ¶
func WithUDPChecker(bindAddr string, resendAttempts int, sleepBetweenResend time.Duration) ServiceOpt
type UDPChecker ¶
type UDPChecker struct {
// contains filtered or unexported fields
}
func NewUDPChecker ¶
func (*UDPChecker) StartHandler ¶
func (u *UDPChecker) StartHandler()
func (*UDPChecker) Stop ¶
func (u *UDPChecker) Stop() error
type Waiter ¶
func (*Waiter) Complete ¶
Complete the waiter with the success condition.
Multiple calls have no effect.
func (*Waiter) DecListeners ¶
func (w *Waiter) DecListeners()
func (*Waiter) IfDisposable ¶
func (w *Waiter) IfDisposable(f func())
func (*Waiter) IncListeners ¶
func (w *Waiter) IncListeners()
Click to show internal directories.
Click to hide internal directories.