當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Address.String方法代碼示例

本文整理匯總了Golang中v2ray/com/core/common/net.Address.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Address.String方法的具體用法?Golang Address.String怎麽用?Golang Address.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在v2ray/com/core/common/net.Address的用法示例。


在下文中一共展示了Address.String方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Dial

func Dial(src v2net.Address, dest v2net.Destination, options internet.DialerOptions) (internet.Connection, error) {
	log.Info("WebSocket|Dailer: Creating connection to ", dest)
	if src == nil {
		src = v2net.AnyIP
	}
	networkSettings, err := options.Stream.GetEffectiveNetworkSettings()
	if err != nil {
		return nil, err
	}
	wsSettings := networkSettings.(*Config)

	id := src.String() + "-" + dest.NetAddr()
	var conn *wsconn
	if dest.Network == v2net.Network_TCP && wsSettings.ConnectionReuse.IsEnabled() {
		connt := globalCache.Get(id)
		if connt != nil {
			conn = connt.(*wsconn)
		}
	}
	if conn == nil {
		var err error
		conn, err = wsDial(src, dest, options)
		if err != nil {
			log.Warning("WebSocket|Dialer: Dial failed: ", err)
			return nil, err
		}
	}
	return NewConnection(id, conn, globalCache, wsSettings), nil
}
開發者ID:xyz12810,項目名稱:v2ray-core,代碼行數:29,代碼來源:dialer.go

示例2: Address

func (v *Assert) Address(value net.Address) *AddressSubject {
	return &AddressSubject{
		Subject: Subject{
			disp: value.String(),
			a:    v,
		},
		value: value,
	}
}
開發者ID:ylywyn,項目名稱:v2ray-core,代碼行數:9,代碼來源:address.go

示例3: Address

func (this *Assert) Address(value v2net.Address) *AddressSubject {
	return &AddressSubject{
		Subject: Subject{
			disp: value.String(),
			a:    this,
		},
		value: value,
	}
}
開發者ID:DZLZHCODE,項目名稱:v2ray-core,代碼行數:9,代碼來源:address.go

示例4: Dial

func Dial(src v2net.Address, dest v2net.Destination) (internet.Connection, error) {
	log.Info("Dailing TCP to ", dest)
	if src == nil {
		src = v2net.AnyIP
	}
	id := src.String() + "-" + dest.NetAddr()
	var conn net.Conn
	if dest.IsTCP() && effectiveConfig.ConnectionReuse {
		conn = globalCache.Get(id)
	}
	if conn == nil {
		var err error
		conn, err = internet.DialToDest(src, dest)
		if err != nil {
			return nil, err
		}
	}
	return NewConnection(id, conn, globalCache), nil
}
開發者ID:DZLZHCODE,項目名稱:v2ray-core,代碼行數:19,代碼來源:dialer.go

示例5: Equals

func (subject *AddressSubject) Equals(another v2net.Address) {
	if !subject.value.Equals(another) {
		subject.Fail("equals to", another.String())
	}
}
開發者ID:DZLZHCODE,項目名稱:v2ray-core,代碼行數:5,代碼來源:address.go

示例6: listenws

func (wsl *WSListener) listenws(address v2net.Address, port v2net.Port) error {
	http.HandleFunc("/"+wsl.config.Path, func(w http.ResponseWriter, r *http.Request) {
		con, err := wsl.converttovws(w, r)
		if err != nil {
			log.Warning("WebSocket|Listener: Failed to convert connection: ", err)
			return
		}

		select {
		case wsl.awaitingConns <- &ConnectionWithError{
			conn: con,
		}:
		default:
			if con != nil {
				con.Close()
			}
		}
		return
	})

	errchan := make(chan error)

	listenerfunc := func() error {
		ol, err := net.Listen("tcp", address.String()+":"+strconv.Itoa(int(port.Value())))
		if err != nil {
			return err
		}
		wsl.listener, err = NewStoppableListener(ol)
		if err != nil {
			return err
		}
		return http.Serve(wsl.listener, nil)
	}

	if wsl.tlsConfig != nil {
		listenerfunc = func() error {
			var err error
			wsl.listener, err = getstopableTLSlistener(wsl.tlsConfig, address.String()+":"+strconv.Itoa(int(port.Value())))
			if err != nil {
				return err
			}
			return http.Serve(wsl.listener, nil)
		}
	}

	go func() {
		err := listenerfunc()
		errchan <- err
		return
	}()

	var err error
	select {
	case err = <-errchan:
	case <-time.After(time.Second * 2):
		//Should this listen fail after 2 sec, it could gone untracked.
	}

	if err != nil {
		log.Error("WebSocket|Listener: Failed to serve: ", err)
	}

	return err

}
開發者ID:xyz12810,項目名稱:v2ray-core,代碼行數:65,代碼來源:hub.go

示例7: NotEquals

func (subject *AddressSubject) NotEquals(another v2net.Address) {
	if subject.value == another {
		subject.Fail("not equals to", another.String())
	}
}
開發者ID:v2ray,項目名稱:v2ray-core,代碼行數:5,代碼來源:address.go

示例8: Equals

func (subject *AddressSubject) Equals(another net.Address) {
	if subject.value != another {
		subject.Fail("equals to", another.String())
	}
}
開發者ID:ylywyn,項目名稱:v2ray-core,代碼行數:5,代碼來源:address.go


注:本文中的v2ray/com/core/common/net.Address.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。