Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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
	}
}
Ejemplo n.º 3
0
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
	}
}