Documentation ¶
Index ¶
- Constants
- func DialAndServe(domain string, port int, handler http.Handler) error
- func DialAndServeReverseProxy(server string, port int, certFile string, domain, target string, insecure bool) error
- func ListenAndServe(grpcAddr, httpAddr, certFile, keyFile string) error
- type Client
- func (c *Client) CheckVersion() error
- func (c *Client) Close() error
- func (c *Client) CreateTunnel() error
- func (c *Client) Dial() error
- func (c *Client) DialAndServe(handler http.Handler) error
- func (c *Client) DialAndServeReverseProxy(target string) error
- func (c *Client) GetTransportCredentials() (creds credentials.TransportCredentials, err error)
- func (c *Client) Listener() (net.Listener, error)
- func (c *Client) Register() error
- func (c *Client) Shutdown() error
- func (c *Client) Worker(errCh chan<- error)
- type Server
- func (s *Server) Authenticated(host, token string) bool
- func (s *Server) CheckVersion(ctx context.Context, req *pb.CheckVersionRequest) (*pb.CheckVersionResponse, error)
- func (s *Server) CreateTunnel(stream pb.Tunnel_CreateTunnelServer) error
- func (s *Server) DialContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (s *Server) ListenAndServe() error
- func (s *Server) Register(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error)
- func (s *Server) Shutdown() error
- func (s *Server) TunnelExists(host string) bool
Constants ¶
const ( // Version is the current hypro version Version = "0.2.0" // MinClientVersion is the current hypro proto version MinClientVersion = "0.2.0" )
Variables ¶
This section is empty.
Functions ¶
func DialAndServe ¶
DialAndServe dials to the hypro server domain:port and then serve on handler on the hypro tunnel Listener
func DialAndServeReverseProxy ¶
func DialAndServeReverseProxy(server string, port int, certFile string, domain, target string, insecure bool) error
DialAndServeReverseProxy dials to the hypro server domain:port and then starts httputil.NewSingleHostReverseProxy on the hypro tunnel Listener
func ListenAndServe ¶
ListenAndServe listens on grpcAddr and http on httpAddr serving hypro tunnel services and http forwarding to the client
Types ¶
type Client ¶
type Client struct { Domain string Server, CertFile string ServerPort int Insecure bool // contains filtered or unexported fields }
Client is a reverse proxy listen on hypro grpc tunnel
func (*Client) CheckVersion ¶
CheckVersion get the versions from server and check
func (*Client) CreateTunnel ¶
CreateTunnel connects to the server and forward to reverse proxy as new net.Conn
func (*Client) DialAndServe ¶
DialAndServe connect to hypro grpc server to receive http request, and serve handler
func (*Client) DialAndServeReverseProxy ¶
DialAndServeReverseProxy connect to hypro grpc server to receive http request, and serve as reverse proxy to the target
func (*Client) GetTransportCredentials ¶
func (c *Client) GetTransportCredentials() (creds credentials.TransportCredentials, err error)
GetTransportCredentials returns tls credentials from cert file or system root ca
type Server ¶
type Server struct {
// the server needs the port to generate full address for the registered domain
GRPCAddr, HTTPAddr, HTTPPort string
CertFile, KeyFile string
pb.UnimplementedTunnelServer
// contains filtered or unexported fields
}
Server is
func (*Server) Authenticated ¶
Authenticated checks valid token from grpc metadata
func (*Server) CheckVersion ¶
func (s *Server) CheckVersion(ctx context.Context, req *pb.CheckVersionRequest) (*pb.CheckVersionResponse, error)
CheckVersion returns the server version and proto version
func (*Server) CreateTunnel ¶
func (s *Server) CreateTunnel(stream pb.Tunnel_CreateTunnelServer) error
CreateTunnel accept and keep connection between client and server TODO: use metadata or custom auth to bind
func (*Server) DialContext ¶
DialContext return a pre-connected proxy connection which actually r/w from grpc
func (*Server) ListenAndServe ¶
ListenAndServe listen on grpc addr and tcp on http addr to provide hypro http proxy through grpc connection with the users
func (*Server) Register ¶
func (s *Server) Register(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error)
Register the client
func (*Server) TunnelExists ¶
TunnelExists checks if the tunnel registered and connected