Documentation
¶
Index ¶
- Constants
- Variables
- 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)
- func SetStructByJSON(obj interface{}, mapData map[string]interface{}) error
- type Control
- type ControlRegistry
- type DBConfig
- 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 User
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 ` )
Variables ¶
var (
DB *gorm.DB
)
GLOBALS
Functions ¶
func LoadTLSConfig ¶
func SetStructByJSON ¶
Types ¶
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
func (*Control) RegisterProxy ¶
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 DBConfig ¶
type DBConfig struct {
Dialect string
Database string
User string
Password string
Host string
Port int
Charset string
URL string
MaxIdleConns int
MaxOpenConns int
ConnMaxLifetime int64
Sslmode string
}
func LoadDbConfig ¶
type KeenIoMetric ¶
type KeenIoMetric struct {
Collection string
Event interface{}
}
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 KeenStruct ¶
type KeenStruct struct {
Timestamp string `json:"timestamp"`
}
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 Tunnel ¶
*
- Tunnel: A control connection, metadata and proxy connections which
- route public traffic to a firewalled endpoint.
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 User ¶
type User struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"deletedAt"`
ActivatedAt *time.Time `json:"activatedAt"`
Name string `json:"name"`
Token string `json:"-"`
Phone string `json:"-"`
Signature string `json:"signature"` //个人签名
Status int `json:"status"`
}
User 用户