| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package net
- import (
- "github.com/v2ray/v2ray-core/common/log"
- )
- const (
- NetTCP = byte(0x01)
- NetUDP = byte(0x02)
- )
- type Destination struct {
- network byte
- address Address
- }
- func NewDestination(network byte, address Address) *Destination {
- return &Destination{
- network: network,
- address: address,
- }
- }
- func (dest *Destination) Network() string {
- switch dest.network {
- case NetTCP:
- return "tcp"
- case NetUDP:
- return "udp"
- default:
- log.Warning("Unknown network %d", dest.network)
- return "tcp"
- }
- }
- func (dest *Destination) NetworkByte() byte {
- return dest.network
- }
- func (dest *Destination) Address() Address {
- return dest.address
- }
- func (dest *Destination) String() string {
- return dest.address.String() + " (" + dest.Network() + ")"
- }
|