Skip to content

Commit ee1a492

Browse files
committed
docs: add docs
1 parent 8cb35a4 commit ee1a492

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed

client/client.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/keyvchan/NetAssist/protocol"
99
)
1010

11+
// Req is the entry point for the client
1112
func Req() {
1213
types := flags.GetArg(2)
1314
log.Println("Req:", types)

pkg/flags/args.go

+3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import (
55
"os"
66
)
77

8+
// args stores the arguments
89
var args []string
910

11+
// SetArgs retrieves the arguments from the command line
1012
func SetArgs() {
1113
args = os.Args
1214
}
1315

16+
// GetArg returns the nth argument
1417
func GetArg(i int) string {
1518
if i < len(args) {
1619
return args[i]

pkg/utils/utils.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
)
77

8+
// Unimplemented is a stub function that returns an error
89
func Unimplemented(message string) {
910
log.Fatal(errors.New("unimplemented: " + message))
1011
}

protocol/tcp.go

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/keyvchan/NetAssist/pkg/message"
1111
)
1212

13+
// TCPServer is a TCP server, read from stdin and write to the client and read from the client write it to stdout
1314
func TCPServer() {
1415
address := flags.GetArg(3)
1516
listener, err := net.Listen("tcp", address)
@@ -41,6 +42,7 @@ func TCPServer() {
4142

4243
}
4344

45+
// accept_conn accepts connections from the listener and adds them to the connections map
4446
func accept_conn(read_chan chan message.Message, listener net.Listener, connections map[net.Conn]bool) {
4547
for {
4648
conn, err := listener.Accept()
@@ -59,6 +61,7 @@ func accept_conn(read_chan chan message.Message, listener net.Listener, connecti
5961

6062
}
6163

64+
// TCPClient is a TCP client, read from stdin and write to the server and read from the server when it to stdout
6265
func TCPClient() {
6366
address := flags.GetArg(3)
6467
conn, err := net.Dial("tcp", address)
@@ -92,6 +95,7 @@ func TCPClient() {
9295
<-quit
9396
}
9497

98+
// conn_cleanup removes closed connections from the connections map
9599
func conn_cleanup(closed_conn chan net.Conn, conns map[net.Conn]bool) {
96100
for {
97101
conn := <-closed_conn
@@ -101,6 +105,7 @@ func conn_cleanup(closed_conn chan net.Conn, conns map[net.Conn]bool) {
101105

102106
}
103107

108+
// write_to_conns writes messages to all connections in the connections map
104109
func write_to_conns(message_chan chan message.Message, connections map[net.Conn]bool) {
105110
for {
106111
message := <-message_chan

protocol/udp.go

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/keyvchan/NetAssist/pkg/message"
1010
)
1111

12+
// UDPServer is a UDP server, it reads from stdin and writes to stdout and read from the client and write to the stdout
1213
func UDPServer() {
1314
address := flags.GetArg(3)
1415
conn, err := net.ListenPacket("udp", address)
@@ -30,6 +31,7 @@ func UDPServer() {
3031
select {}
3132
}
3233

34+
// UDPClient is a UDP client, it reads from stdin and writes to stdout and read from the server and write to the stdout
3335
func UDPClient() {
3436
address := flags.GetArg(3)
3537
conn, err := net.Dial("udp", address)

protocol/unix.go

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/keyvchan/NetAssist/pkg/flags"
1212
)
1313

14+
// UnixServer is a server for the unix socket, it bridged server to stdout and stdin to server
1415
func UnixServer() {
1516
address := flags.GetArg(3)
1617
listener, err := net.Listen("unix", address)
@@ -33,6 +34,7 @@ func UnixServer() {
3334

3435
}
3536

37+
// UnixClient is a client for the unix socket, it bridged stdin to server and server to stdout
3638
func UnixClient() {
3739
address := flags.GetArg(3)
3840
conn, err := net.Dial("unix", address)

protocol/unixgram.go

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/keyvchan/NetAssist/pkg/flags"
1212
)
1313

14+
// UnixgramServer is a server for the unixgram protocol, its create a bridge between server and client
1415
func UnixgramServer() {
1516
address := flags.GetArg(3)
1617
conn, err := net.ListenPacket("unixgram", address)
@@ -24,6 +25,7 @@ func UnixgramServer() {
2425
}
2526
}
2627

28+
// UnixgramClient is a client for the unixgram protocol, its create a bridge between server and client
2729
func UnixgramClient() {
2830
address := flags.GetArg(3)
2931
conn, err := net.Dial("unixgram", address)

0 commit comments

Comments
 (0)