github.com/sagernet/quic-go@v0.43.1-beta.1/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 }