当前位置: 首页>>代码示例>>Golang>>正文


Golang Port.Value方法代码示例

本文整理汇总了Golang中v2ray/com/core/common/net.Port.Value方法的典型用法代码示例。如果您正苦于以下问题:Golang Port.Value方法的具体用法?Golang Port.Value怎么用?Golang Port.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在v2ray/com/core/common/net.Port的用法示例。


在下文中一共展示了Port.Value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewSocks4AuthenticationResponse

func NewSocks4AuthenticationResponse(result byte, port v2net.Port, ip []byte) *Socks4AuthenticationResponse {
	return &Socks4AuthenticationResponse{
		result: result,
		port:   port.Value(),
		ip:     ip,
	}
}
开发者ID:DZLZHCODE,项目名称:v2ray-core,代码行数:7,代码来源:socks4.go

示例2: writeSocks4Response

func writeSocks4Response(writer io.Writer, errCode byte, address v2net.Address, port v2net.Port) error {
	buffer := buf.NewLocal(32)
	buffer.AppendBytes(0x00, errCode)
	buffer.AppendSupplier(serial.WriteUint16(port.Value()))
	buffer.Append(address.IP())
	_, err := writer.Write(buffer.Bytes())
	return err
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:8,代码来源:protocol.go

示例3: appendAddress

func appendAddress(buffer *buf.Buffer, address v2net.Address, port v2net.Port) {
	switch address.Family() {
	case v2net.AddressFamilyIPv4:
		buffer.AppendBytes(0x01)
		buffer.Append(address.IP())
	case v2net.AddressFamilyIPv6:
		buffer.AppendBytes(0x04)
		buffer.Append(address.IP())
	case v2net.AddressFamilyDomain:
		buffer.AppendBytes(0x03, byte(len(address.Domain())))
		buffer.AppendSupplier(serial.WriteString(address.Domain()))
	}
	buffer.AppendSupplier(serial.WriteUint16(port.Value()))
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:14,代码来源:protocol.go

示例4: LessThan

func (subject *PortSubject) LessThan(expectation net.Port) {
	if subject.value.Value() >= expectation.Value() {
		subject.Fail("is less than", expectation.String())
	}
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:5,代码来源:port.go

示例5: GreaterThan

func (subject *PortSubject) GreaterThan(expectation net.Port) {
	if subject.value.Value() <= expectation.Value() {
		subject.Fail("is greater than", expectation.String())
	}
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:5,代码来源:port.go

示例6: Equals

func (subject *PortSubject) Equals(expectation net.Port) {
	if subject.value.Value() != expectation.Value() {
		subject.Fail("is equal to", expectation.String())
	}
}
开发者ID:ylywyn,项目名称:v2ray-core,代码行数:5,代码来源:port.go

示例7: 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


注:本文中的v2ray/com/core/common/net.Port.Value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。