0.2.1
This commit is contained in:
@@ -68,15 +68,15 @@ func (c *Client) Start() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert callback type to match interface
|
callback := common.PacketCallback(func(data []byte, iface interface{}) {
|
||||||
callback := func(data []byte, iface interface{}) {
|
|
||||||
c.transport.HandlePacket(data, iface)
|
c.transport.HandlePacket(data, iface)
|
||||||
}
|
})
|
||||||
client.SetPacketCallback(common.PacketCallback(callback))
|
client.SetPacketCallback(callback)
|
||||||
iface = client
|
iface = client
|
||||||
|
|
||||||
case "udp":
|
case "udp":
|
||||||
addr := fmt.Sprintf("%s:%d", ifaceConfig.Address, ifaceConfig.Port)
|
addr := fmt.Sprintf("%s:%d", ifaceConfig.Address, ifaceConfig.Port)
|
||||||
|
|
||||||
udp, err := interfaces.NewUDPInterface(
|
udp, err := interfaces.NewUDPInterface(
|
||||||
ifaceConfig.Name,
|
ifaceConfig.Name,
|
||||||
addr,
|
addr,
|
||||||
@@ -87,11 +87,10 @@ func (c *Client) Start() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert callback type to match interface
|
callback := common.PacketCallback(func(data []byte, iface interface{}) {
|
||||||
callback := func(data []byte, iface interface{}) {
|
|
||||||
c.transport.HandlePacket(data, iface)
|
c.transport.HandlePacket(data, iface)
|
||||||
}
|
})
|
||||||
udp.SetPacketCallback(common.PacketCallback(callback))
|
udp.SetPacketCallback(callback)
|
||||||
iface = udp
|
iface = udp
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
type InterfaceMode byte
|
type InterfaceMode byte
|
||||||
type InterfaceType byte
|
type InterfaceType byte
|
||||||
|
|
||||||
type PacketCallback func([]byte, interface{})
|
type PacketCallback = func([]byte, interface{})
|
||||||
|
|
||||||
// NetworkInterface combines both low-level and high-level interface requirements
|
// NetworkInterface combines both low-level and high-level interface requirements
|
||||||
type NetworkInterface interface {
|
type NetworkInterface interface {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ type TCPClientInterface struct {
|
|||||||
maxReconnectTries int
|
maxReconnectTries int
|
||||||
packetBuffer []byte
|
packetBuffer []byte
|
||||||
packetType byte
|
packetType byte
|
||||||
packetCallback func([]byte, interface{})
|
packetCallback common.PacketCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTCPClient(name string, targetAddr string, targetPort int, kissFraming bool, i2pTunneled bool) (*TCPClientInterface, error) {
|
func NewTCPClient(name string, targetAddr string, targetPort int, kissFraming bool, i2pTunneled bool) (*TCPClientInterface, error) {
|
||||||
@@ -273,7 +273,7 @@ func escapeKISS(data []byte) []byte {
|
|||||||
return escaped
|
return escaped
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tc *TCPClientInterface) SetPacketCallback(cb func([]byte, interface{})) {
|
func (tc *TCPClientInterface) SetPacketCallback(cb common.PacketCallback) {
|
||||||
tc.packetCallback = cb
|
tc.packetCallback = cb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user