Documentation ¶
Index ¶
- Constants
- func ConfigMain()
- func LoadTLSConfig(crtPath string, keyPath string) (tlsConfig *tls.Config, err error)
- func Main()
- func NewControl(ctlConn conn.Conn, authMsg *msg.Auth)
- func NewProxy(pxyConn conn.Conn, regPxy *msg.RegProxy)
- type ConfigMgr
- func (mgr *ConfigMgr) AddUserConfig(uc *UserConfig) error
- func (mgr *ConfigMgr) BindUser(id string, user string) error
- func (mgr *ConfigMgr) GetByDns(dns string) *UserInfo
- func (mgr *ConfigMgr) GetUserInfo(id string) *UserInfo
- func (mgr *ConfigMgr) ListAll() []string
- func (mgr *ConfigMgr) TimeoutAllDays()
- type Control
- type ControlRegistry
- type Db
- type DbProvider
- type KeenIoMetric
- type KeenIoMetrics
- func (k *KeenIoMetrics) AuthedRequest(method, path string, body *bytes.Reader) (resp *http.Response, err error)
- func (k *KeenIoMetrics) CloseConnection(t *Tunnel, c conn.Conn, start time.Time, in, out int64)
- func (k *KeenIoMetrics) CloseTunnel(t *Tunnel)
- func (k *KeenIoMetrics) OpenConnection(t *Tunnel, c conn.Conn)
- func (k *KeenIoMetrics) OpenTunnel(t *Tunnel)
- type KeenStruct
- type LocalMetrics
- type Metrics
- type Options
- type Tunnel
- type TunnelRegistry
- func (r *TunnelRegistry) Del(url string)
- func (r *TunnelRegistry) Get(url string) *Tunnel
- func (r *TunnelRegistry) GetCachedRegistration(t *Tunnel) (url string)
- func (r *TunnelRegistry) Register(url string, t *Tunnel) error
- func (r *TunnelRegistry) RegisterAndCache(url string, t *Tunnel) (err error)
- func (r *TunnelRegistry) RegisterRepeat(urlFn func() string, t *Tunnel) (string, error)
- func (r *TunnelRegistry) SaveCacheThread(path string, interval time.Duration)
- type UserConfig
- type UserInfo
Constants ¶
const ( NotAuthorized = `HTTP/1.0 401 Not Authorized WWW-Authenticate: Basic realm="ngrok" Content-Length: 23 Authorization required ` NotFound = `HTTP/1.0 404 Not Found Content-Length: %d Tunnel %s not found ` BadRequest = `HTTP/1.0 400 Bad Request Content-Length: 12 Bad Request ` )
const (
DbPrefix = "ngrok"
)
Variables ¶
This section is empty.
Functions ¶
func ConfigMain ¶
func ConfigMain()
func LoadTLSConfig ¶
func Main ¶
func Main()
Types ¶
type ConfigMgr ¶
type ConfigMgr struct {
// contains filtered or unexported fields
}
func (*ConfigMgr) AddUserConfig ¶
func (mgr *ConfigMgr) AddUserConfig(uc *UserConfig) error
Add new config, but not save to db
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
func (*Control) GetProxy ¶
Remove a proxy connection from the pool and return it If not proxy connections are in the pool, request one and wait until it is available Returns an error if we couldn't get a proxy because it took too long or the tunnel is closing
type ControlRegistry ¶
ControlRegistry maps a client ID to Control structures
func NewControlRegistry ¶
func NewControlRegistry() *ControlRegistry
func (*ControlRegistry) Add ¶
func (r *ControlRegistry) Add(clientId string, ctl *Control) (oldCtl *Control)
func (*ControlRegistry) Del ¶
func (r *ControlRegistry) Del(clientId string) error
func (*ControlRegistry) Get ¶
func (r *ControlRegistry) Get(clientId string) *Control
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
func (*Db) Save ¶
func (db *Db) Save(mgr *ConfigMgr, uc *UserConfig) error
type DbProvider ¶
type DbProvider interface { Save(mgr *ConfigMgr, config *UserConfig) error LoadAll(mgr *ConfigMgr) error }
type KeenIoMetrics ¶
type KeenIoMetrics struct { log.Logger ApiKey string ProjectToken string HttpClient http.Client Metrics chan *KeenIoMetric }
func NewKeenIoMetrics ¶
func NewKeenIoMetrics(batchInterval time.Duration) *KeenIoMetrics
func (*KeenIoMetrics) AuthedRequest ¶
func (*KeenIoMetrics) CloseConnection ¶
func (*KeenIoMetrics) CloseTunnel ¶
func (k *KeenIoMetrics) CloseTunnel(t *Tunnel)
func (*KeenIoMetrics) OpenConnection ¶
func (k *KeenIoMetrics) OpenConnection(t *Tunnel, c conn.Conn)
func (*KeenIoMetrics) OpenTunnel ¶
func (k *KeenIoMetrics) OpenTunnel(t *Tunnel)
type LocalMetrics ¶
func NewLocalMetrics ¶
func NewLocalMetrics(reportInterval time.Duration) *LocalMetrics
func (*LocalMetrics) CloseConnection ¶
func (*LocalMetrics) CloseTunnel ¶
func (m *LocalMetrics) CloseTunnel(t *Tunnel)
func (*LocalMetrics) OpenConnection ¶
func (m *LocalMetrics) OpenConnection(t *Tunnel, c conn.Conn)
func (*LocalMetrics) OpenTunnel ¶
func (m *LocalMetrics) OpenTunnel(t *Tunnel)
func (*LocalMetrics) Report ¶
func (m *LocalMetrics) Report()
type Metrics ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
type Tunnel ¶
*
- Tunnel: A control connection, metadata and proxy connections which
- route public traffic to a firewalled endpoint.
func NewTunnel ¶
Create a new tunnel from a registration message received on a control channel
func (*Tunnel) HandlePublicConnection ¶
type TunnelRegistry ¶
TunnelRegistry maps a tunnel URL to Tunnel structures
func NewTunnelRegistry ¶
func NewTunnelRegistry(cacheSize uint64, cacheFile string) *TunnelRegistry
func (*TunnelRegistry) Del ¶
func (r *TunnelRegistry) Del(url string)
func (*TunnelRegistry) Get ¶
func (r *TunnelRegistry) Get(url string) *Tunnel
func (*TunnelRegistry) GetCachedRegistration ¶
func (r *TunnelRegistry) GetCachedRegistration(t *Tunnel) (url string)
func (*TunnelRegistry) Register ¶
func (r *TunnelRegistry) Register(url string, t *Tunnel) error
Register a tunnel with a specific url, returns an error if a tunnel is already registered at that url
func (*TunnelRegistry) RegisterAndCache ¶
func (r *TunnelRegistry) RegisterAndCache(url string, t *Tunnel) (err error)
func (*TunnelRegistry) RegisterRepeat ¶
func (r *TunnelRegistry) RegisterRepeat(urlFn func() string, t *Tunnel) (string, error)
Register a tunnel with the following process: Consult the affinity cache to try to assign a previously used tunnel url if possible Generate new urls repeatedly with the urlFn and register until one is available.
func (*TunnelRegistry) SaveCacheThread ¶
func (r *TunnelRegistry) SaveCacheThread(path string, interval time.Duration)
Spawns a goroutine the periodically saves the cache to a file.
type UserConfig ¶
type UserInfo ¶
type UserInfo struct { Uc *UserConfig TransPerDay int32 TransAll int32 }