github.com/psiphon-Labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/quic/gquic-go/internal/protocol/perspective.go (about)

     1  package protocol
     2  
     3  // Perspective determines if we're acting as a server or a client
     4  type Perspective int
     5  
     6  // the perspectives
     7  const (
     8  	PerspectiveServer Perspective = 1
     9  	PerspectiveClient Perspective = 2
    10  )
    11  
    12  // Opposite returns the perspective of the peer
    13  func (p Perspective) Opposite() Perspective {
    14  	return 3 - p
    15  }
    16  
    17  func (p Perspective) String() string {
    18  	switch p {
    19  	case PerspectiveServer:
    20  		return "Server"
    21  	case PerspectiveClient:
    22  		return "Client"
    23  	default:
    24  		return "invalid perspective"
    25  	}
    26  }