This commit is contained in:
Sudo-Ivan
2024-12-30 03:50:52 -06:00
parent 0f5f5cbb13
commit decbd8f29a
16 changed files with 1046 additions and 970 deletions

View File

@@ -6,11 +6,6 @@ import (
"time"
)
type InterfaceMode byte
type InterfaceType byte
type PacketCallback = func([]byte, interface{})
// NetworkInterface combines both low-level and high-level interface requirements
type NetworkInterface interface {
// Low-level network operations
@@ -21,7 +16,7 @@ type NetworkInterface interface {
GetType() InterfaceType
GetMode() InterfaceMode
GetMTU() int
// High-level packet operations
ProcessIncoming([]byte)
ProcessOutgoing([]byte) error
@@ -29,7 +24,7 @@ type NetworkInterface interface {
SendLinkPacket([]byte, []byte, time.Time) error
Detach()
SetPacketCallback(PacketCallback)
// Additional required fields
GetName() string
GetConn() net.Conn
@@ -38,23 +33,23 @@ type NetworkInterface interface {
// BaseInterface provides common implementation
type BaseInterface struct {
Name string
Mode InterfaceMode
Type InterfaceType
Name string
Mode InterfaceMode
Type InterfaceType
Online bool
Detached bool
IN bool
OUT bool
MTU int
Bitrate int64
TxBytes uint64
RxBytes uint64
Mutex sync.RWMutex
Owner interface{}
IN bool
OUT bool
MTU int
Bitrate int64
TxBytes uint64
RxBytes uint64
Mutex sync.RWMutex
Owner interface{}
PacketCallback PacketCallback
}
}

View File

@@ -10,15 +10,15 @@ type PathStatus byte
// Common structs
type Path struct {
Interface NetworkInterface
LastSeen time.Time
NextHop []byte
Hops uint8
LastUpdated time.Time
Interface NetworkInterface
LastSeen time.Time
NextHop []byte
Hops uint8
LastUpdated time.Time
}
// Common callbacks
type ProofRequestedCallback func(interface{}) bool
type ProofRequestedCallback func([]byte, []byte)
type LinkEstablishedCallback func(interface{})
// Request handler
@@ -27,4 +27,10 @@ type RequestHandler struct {
ResponseGenerator func(path string, data []byte, requestID []byte, linkID []byte, remoteIdentity interface{}, requestedAt int64) []byte
AllowMode byte
AllowedList [][]byte
}
}
type InterfaceMode byte
type InterfaceType byte
// PacketCallback defines the function signature for packet handling
type PacketCallback func([]byte, interface{})