github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/ChaparKhane/user-connection.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package chaparkhane
     4  
     5  import "../crypto"
     6  
     7  // UserConnection can use by any type users
     8  type UserConnection struct {
     9  	/* Connection data */
    10  	UserConnectionID [16]byte
    11  	UserGPID         uint32 // Part of GP that lease by OS delegate of a user!
    12  	Status           uint8  // States locate in this file.
    13  	Weight           uint8  // 16 queue for priority weight of the connections exist.
    14  	MaxBandwidth     uint64 // Peer must respect this, otherwise connection will terminate and User go to black list!
    15  
    16  	/* Peer data */
    17  	Path            []byte // Chapar switch spec
    18  	ReversePath     []byte // Chapar switch spec
    19  	AlternativePath [][]byte
    20  	ThingID         [16]byte
    21  	UserID          [16]byte // Can't change after first set. 0 for Guest!
    22  	UserType        uint8    // 0:Guest, 1:Registered 2:Person, 3:Org, 4:App, ...
    23  
    24  	/* Security data */
    25  	PeerPublicKey [32]byte
    26  	Cipher        crypto.Cipher // Selected cipher algorithms https://en.wikipedia.org/wiki/Cipher_suite
    27  
    28  	/* Metrics data */
    29  	BytesSent             uint64 // Counts the bytes of payload data sent.
    30  	PacketsSent           uint64 // Counts packets sent.
    31  	BytesReceived         uint64 // Counts the bytes of payload data Receive.
    32  	PacketsReceived       uint64 // Counts packets Receive.
    33  	FailedPacketsReceived uint64 // Counts failed packets receive for firewalling server from some attack types!
    34  }
    35  
    36  // UserConnection Status
    37  const (
    38  	// UserConnectionStateClosed indicate connection had been closed
    39  	UserConnectionStateClosed uint8 = iota
    40  	// UserConnectionStateOpen indicate connection is open and ready to use
    41  	UserConnectionStateOpen
    42  	// UserConnectionStateRateLimited indicate connection limited due to higher usage than permitted!
    43  	UserConnectionStateRateLimited
    44  	// UserConnectionStateOpening indicate connection plan to open and not ready to accept stream!
    45  	UserConnectionStateOpening
    46  	// UserConnectionStateClosing indicate connection plan to close and not accept new stream
    47  	UserConnectionStateClosing
    48  	// UserConnectionStateNotResponse indicate peer not response to recently send request!
    49  	UserConnectionStateNotResponse
    50  )