コード例 #1
0
ファイル: conn.go プロジェクト: postfix/go-tunnel
func wrapConn(conn net.Conn, tags ...string) *Logged {
	switch c := conn.(type) {
	case *Logged:
		return c
	default:
		logged := &Logged{Conn: conn, Logger: log.NewTaggedLogger(util.RandId(4))}
		logged.AddTags(tags...)
		return logged
	}

	return nil
}
コード例 #2
0
ファイル: interface.go プロジェクト: 40a/go-tunnel
func pickName(hostname, subdomain, publicBaseAddr string) (url string, israndom bool) {
	// normalize names
	hostname = normalize(hostname)
	subdomain = normalize(subdomain)

	// register for specific hostname
	if hostname != "" {
		return hostname, false

		// register for specific subdomain
	} else if subdomain != "" {
		return fmt.Sprintf("%s.%s", subdomain, publicBaseAddr), false

		// register for random subdomain
	} else {
		return fmt.Sprintf("%s.%s", util.RandId(4), publicBaseAddr), true
	}
}
コード例 #3
0
ファイル: http.go プロジェクト: RandomStuffs22/go-tunnel
func (b *HTTPBinder) pickName(opts *proto.HTTPOptions) (url string, isRandom bool) {
	// normalize names
	hostname := normalize(opts.Hostname)
	subdomain := normalize(opts.Subdomain)

	// Register for specific hostname
	if hostname != "" {
		return hostname, false

		// Register for specific subdomain
	} else if subdomain != "" {
		return fmt.Sprintf("%s.%s", subdomain, b.publicBaseAddr), false

		// Register for random subdomain
	} else {
		return fmt.Sprintf("%s.%s", util.RandId(4), b.publicBaseAddr), true
	}
}