network

package
v0.3.0-alpha5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Thorben Krüger (thorben.krueger@ovgu.de)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	NETWORK_IP    = "IP"
	NETWORK_IPV4  = "IPv4"
	NETWORK_IPV6  = "IPv6"
	NETWORK_SCION = "SCION"

	TRANSPORT_UDP  = "UDP"
	TRANSPORT_TCP  = "TCP"
	TRANSPORT_QUIC = "QUIC"
)

Variables

View Source
var (
	NetTypeError  = errors.New("invalid network type")
	AddrTypeError = errors.New("invalid address type")
	EOM           = errors.New("End of Message")
	NewlineError  = errors.New("Invalid String for Message (contains Newlines)")
)

Functions

This section is empty.

Types

type Connection

type Connection interface {
	io.ReadWriteCloser
	Send(Message) error
	Receive(Message) error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetError(error)
	GetError() error
}

func NewQUIC

func NewQUIC(conn quic.Session, stream quic.Stream, laddr, raddr net.Addr) Connection

func NewTCP

func NewTCP(conn *net.TCPConn, laddr, raddr net.Addr) Connection

func NewUDP

func NewUDP(conn net.Conn, pconn net.PacketConn, laddr, raddr net.Addr) Connection

type Dialer

type Dialer interface {
	Dial() (Connection, error)
}

type Endpoint

type Endpoint struct {
	Local         bool
	LocalAddress  string
	RemoteAddress string
	Transport     string
	Network       string
}

func NewLocalEndpoint

func NewLocalEndpoint() *Endpoint

func NewRemoteEndpoint

func NewRemoteEndpoint() *Endpoint

func (*Endpoint) WithAddress

func (e *Endpoint) WithAddress(addr string)

func (*Endpoint) WithNetwork

func (e *Endpoint) WithNetwork(network string)

func (*Endpoint) WithTransport

func (e *Endpoint) WithTransport(transport string)

type FixedMessage

type FixedMessage struct {
	// contains filtered or unexported fields
}

func NewFixedMessage

func NewFixedMessage(size int) *FixedMessage

func NewFixedMessageString

func NewFixedMessageString(s string) *FixedMessage

func (FixedMessage) Read

func (m FixedMessage) Read(p []byte) (i int, err error)

TODO, add proper locking and reusability of buffer

func (FixedMessage) String

func (m FixedMessage) String() string

func (FixedMessage) Write

func (m FixedMessage) Write(p []byte) (i int, err error)

Write appends the contents of p to the message m, return error network.EOM when the capacity is met or exceeded

type LineMessage

type LineMessage struct {
	// contains filtered or unexported fields
}

func NewLineMessage

func NewLineMessage() *LineMessage

func NewLineMessageString

func NewLineMessageString(s string) (*LineMessage, error)

func (LineMessage) Read

func (m LineMessage) Read(p []byte) (int, error)

func (LineMessage) String

func (m LineMessage) String() string

func (LineMessage) Write

func (m LineMessage) Write(p []byte) (int, error)

Write the contents of p into this message m, return error network.EOM when a newline is found

type Listener

type Listener interface {
	Listen() (Connection, error)
	Stop() error
}

type Message

type Message interface {
	String() string
	io.ReadWriter
}

type Network

type Network interface {
	NewListener(*Endpoint) (Listener, error)
	NewDialer(*Endpoint) (Dialer, error)
}

type Preconnection

type Preconnection interface {
	Listen() (Listener, error)
	Initiate() (Connection, error)
}

type QUIC

type QUIC struct {
	// contains filtered or unexported fields
}

func (*QUIC) Close

func (c *QUIC) Close() error

func (*QUIC) GetError

func (c *QUIC) GetError() error

func (*QUIC) LocalAddr

func (c *QUIC) LocalAddr() net.Addr

func (*QUIC) Read

func (c *QUIC) Read(p []byte) (n int, err error)

func (*QUIC) Receive

func (c *QUIC) Receive(message Message) error

func (*QUIC) RemoteAddr

func (c *QUIC) RemoteAddr() net.Addr

func (*QUIC) Send

func (c *QUIC) Send(message Message) error

func (*QUIC) SetError

func (c *QUIC) SetError(err error)

func (*QUIC) Write

func (c *QUIC) Write(p []byte) (n int, err error)

type TCP

type TCP struct {
	// contains filtered or unexported fields
}

func (*TCP) Close

func (c *TCP) Close() error

func (*TCP) GetError

func (c *TCP) GetError() error

func (*TCP) LocalAddr

func (c *TCP) LocalAddr() net.Addr

func (*TCP) Read

func (c *TCP) Read(p []byte) (int, error)

func (*TCP) Receive

func (c *TCP) Receive(m Message) error

func (*TCP) RemoteAddr

func (c *TCP) RemoteAddr() net.Addr

func (*TCP) Send

func (c *TCP) Send(message Message) error

func (*TCP) SetError

func (c *TCP) SetError(err error)

func (*TCP) Write

func (c *TCP) Write(p []byte) (int, error)

type TransportProperties

type TransportProperties struct {
	Properties      map[string]string
	RequireProhibit map[string]bool
	PreferAvoid     map[string]bool
}

func NewTransportProperties

func NewTransportProperties() *TransportProperties

func (*TransportProperties) Avoid

func (tp *TransportProperties) Avoid(property string)

func (*TransportProperties) Ignore

func (tp *TransportProperties) Ignore(property string)

func (*TransportProperties) Prefer

func (tp *TransportProperties) Prefer(property string)

func (*TransportProperties) Prohibit

func (tp *TransportProperties) Prohibit(property string)

func (*TransportProperties) Require

func (tp *TransportProperties) Require(property string)

func (*TransportProperties) Set

func (tp *TransportProperties) Set(property, value string)

type UDP

type UDP struct {
	// contains filtered or unexported fields
}

func (*UDP) Close

func (c *UDP) Close() error

func (*UDP) GetError

func (c *UDP) GetError() error

func (*UDP) LocalAddr

func (c *UDP) LocalAddr() net.Addr

func (*UDP) Read

func (c *UDP) Read(p []byte) (n int, err error)

func (*UDP) Receive

func (c *UDP) Receive(m Message) error

func (*UDP) RemoteAddr

func (c *UDP) RemoteAddr() net.Addr

func (*UDP) Send

func (c *UDP) Send(message Message) error

func (*UDP) SetError

func (c *UDP) SetError(err error)

func (*UDP) Write

func (c *UDP) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL