cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2021.12.3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

datagramsession/event.go

50lines · modecode

1package datagramsession
2
3import (
4 "fmt"
5 "io"
6
7 "github.com/google/uuid"
8)
9
10// registerSessionEvent is an event to start tracking a new session
11type registerSessionEvent struct {
12 sessionID uuid.UUID
13 originProxy io.ReadWriteCloser
14 resultChan chan *Session
15}
16
17func newRegisterSessionEvent(sessionID uuid.UUID, originProxy io.ReadWriteCloser) *registerSessionEvent {
18 return &registerSessionEvent{
19 sessionID: sessionID,
20 originProxy: originProxy,
21 resultChan: make(chan *Session, 1),
22 }
23}
24
25// unregisterSessionEvent is an event to stop tracking and terminate the session.
26type unregisterSessionEvent struct {
27 sessionID uuid.UUID
28 err *errClosedSession
29}
30
31// ClosedSessionError represent a condition that closes the session other than I/O
32// I/O error is not included, because the side that closes the session is ambiguous.
33type errClosedSession struct {
34 message string
35 byRemote bool
36}
37
38func (sc *errClosedSession) Error() string {
39 if sc.byRemote {
40 return fmt.Sprintf("session closed by remote due to %s", sc.message)
41 } else {
42 return fmt.Sprintf("session closed by local due to %s", sc.message)
43 }
44}
45
46// newDatagram is an event when transport receives new datagram
47type newDatagram struct {
48 sessionID uuid.UUID
49 payload []byte
50}
51