Browse Source

net-cat

content-update
lee 5 years ago
parent
commit
a097b60699
  1. 29
      subjects/net-cat/net-cat.audit.en.md
  2. 188
      subjects/net-cat/net-cat.en.md

29
subjects/net-cat/net-cat.audit.en.md

@ -1,13 +1,19 @@
#### Functional #### Functional
##### Try running `"./net-cat -p 8080"`. ##### Try running `"./TCPChat"`.
###### Is the server listening for connections? ###### Is the server listening for connections on the default port?
##### Try opening 3 terminals, run on the first terminal the command `"./net-cat -p <port>"` and on the second and third terminal run the command `"./net-cat <host ip> <port>"`. ##### Try running `"./TCPChat" 2525 localhost`.
###### Did server respond with usage?
##### Try running `"./TCPChat 2525"`.
###### Is the server listening for connections on the port 2525?
##### Try opening 3 terminals, run on the first terminal the command `"./TCPChat <port>"` and on the second and third terminal run the command `"nc <host ip> <port>"`.
###### Does both clients connect to the server with success? ###### Does both clients connect to the server with success?
##### Try opening 4 terminals, run on the first terminal the command `"./net-cat -u -p <port>"` and on the second, third and fourth terminal run the command `"./net-cat -u <host ip> <port>"`. ##### Try creating a server and 2 Clients.
###### Does all clients connect to the server with [UDP](https://www.privateinternetaccess.com/blog/2018/12/tcp-vs-udp-understanding-the-difference/) connection? ###### Did server respond you with linux logo and asked for the name?
##### Try creating a server and 2 Clients. ##### Try creating a server and 2 Clients.
###### Do all Clients receive a message informing that the Client joined the chat? ###### Do all Clients receive a message informing that the Client joined the chat?
@ -31,16 +37,27 @@
###### Does the rest of the Clients receive a message notifying that the Client left? ###### Does the rest of the Clients receive a message notifying that the Client left?
##### Try creating a server and 3 Clients. Then send messages between the Clients. ##### Try creating a server and 3 Clients. Then send messages between the Clients.
###### Are the messages identified by the name of each Client and the time that the messages was sent? ```
[2020-01-20 15:48:41][client.name]:[client.message]
```
###### Are the messages identified by the name of each Client and the time that the messages was sent, as above?
###### Is the connections between server and Clients well established? ###### Is the connections between server and Clients well established?
###### Does the project present go routines?
###### Does the project use channels or mutexe?
##### Are the students using just the allowed functions?
#### General #### General
###### +Can the Clients change their names? ###### +Can the Clients change their names?
###### +Is the chat group informed if a Client changes his name? ###### +Is the chat group informed if a Client changes his name?
###### +Does the server produce logs about Clients activities? ###### +Does the server produce logs about Clients activities?
###### +Does the server logs saved into a file?
###### +Is there more NetCat flags implemented? ###### +Is there more NetCat flags implemented?
###### +Does the project present a Terminal UI using JUST this package : https://github.com/jroimartin/gocui?
#### Basic #### Basic

188
subjects/net-cat/net-cat.en.md

@ -31,17 +31,20 @@ Here is a simple example of connection and transmission between Server-Client by
- To see the host IP use the command `ifconfig` on the server host machine. - To see the host IP use the command `ifconfig` on the server host machine.
Your project must work in a similar way that NetCat works, in other words, you must create a group chat. The project must present : Your project must work in a similar way that NetCat works, in other words, you must create a group chat. The project must have the following features :
- TCP or UDP connection between server and multiple clients (relation of 1 to many). The type of connection must be established by using a flag, just like `nc`, by default it uses TCP connection, but if you want to use UDP connection present the flag `-u`. - TCP connection between server and multiple clients (relation of 1 to many).
- Each Client must have an user name. - A name requirement to the client.
- Control connections quantity.
- Clients must be able to send messages to the chat. - Clients must be able to send messages to the chat.
- Messages sent, must be identified by the time that was sent and the user name of who sent the message. - Do not broadcast EMPTY messages from a client.
- Messages sent, must be identified by the time that was sent and the user name of who sent the message, example : `[2020-01-20 15:48:41][client.name]:[client.message]`
- If a Client joins the chat, all the previous messages sent to the chat must be uploaded to the new Client. - If a Client joins the chat, all the previous messages sent to the chat must be uploaded to the new Client.
- If a Client connects to the server, the rest of the Clients must be informed by the server that the Client joined the group. - If a Client connects to the server, the rest of the Clients must be informed by the server that the Client joined the group.
- If a Client exits the chat, the rest of the Clients must be informed by the server that the Client left. - If a Client exits the chat, the rest of the Clients must be informed by the server that the Client left.
- All Clients must receive the messages sent by other Clients. - All Clients must receive the messages sent by other Clients.
- If a Client leaves the chat, the rest of the Clients must not disconnect. - If a Client leaves the chat, the rest of the Clients must not disconnect.
- If there is no port specified, then set as default the port 8080. Otherwise, program must respond with usage message: `[USAGE]: ./TCPChat $port`
This project will help you learn about : This project will help you learn about :
@ -52,70 +55,163 @@ This project will help you learn about :
- TCP/UDP socket - TCP/UDP socket
- [Channels](https://tour.golang.org/concurrency/2) - [Channels](https://tour.golang.org/concurrency/2)
- [Goroutines](https://tour.golang.org/concurrency/1) - [Goroutines](https://tour.golang.org/concurrency/1)
- Mutexes
- IP and [ports](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers) - IP and [ports](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers)
### Hints
- Try to find out more about the flags `-u`, `-p` and `-l`.
### Instructions ### Instructions
- Your project must be written in **Go**. - Your project must be written in **Go**
- Your project must use TCP or UDP. - Start TCP server, listen and accept connections
- The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices.en). - Your project must have Go-routines
- It is recommended that the code should present a **test file** for the server connection and the client connection. - Your project must have channels or Mutexes
- You have to be able to handle the errors from server side and client side. - Maximum 10 connections
- The code must respect the [**good practices**](https://public.01-edu.org/subjects/good-practices.en)
- It is recommended that the code should present a **test file** for the server connection and the client connection
- You have to be able to handle the errors from server side and client side
### Allowed Packages
- io
- log
- os
- fmt
- net
- sync
- time
- bufio
- errors
- strings
- reflect
### Usage ### Usage
Here is a simple example of a group chat : ```console
student$ go build
student$ ./TCPChat
Listening on the port :8080
student$ ./TCPChat 2525
Listening on the port :2525
student$ ./TCPChat 2525 localhost
[USAGE]: ./TCPChat $port
```
- Server side : - You should answer the client with a linux logo and ask for their name, when connection is received
```console ```console
student$ ./net-cat -p 8080 student$ nc $IP $port
listening on port 8080.... Welcome to TCP-Chat!
_nnnn_
dGGGGMMb
@p~qp~~qMb
M|@||@) M|
@,----.JM|
JS^\__/ qKL
dZP qKRb
dZP qKKb
fZP SMMb
HZM MMMM
FqM MMMM
__| ". |\dS"qML
| `. | `' \Zq
_) \.___.,| .'
\____ )MMMMMP| .'
`-' `--'
[ENTER YOUR NAME]:
``` ```
- Two Clients running at the same time - Accept connection with non-empty name
- Client 2 : The client :
```console ```console
student$ ./net-cat 192.168.1.123 8080 student$ nc $IP $port
welcome, you are connected ```
enter user name : client2 Server:
your name is client2
client2 joined the chat... ```console
client1 joined the chat... student$ ./TCPChat 2525
Listening on the port :2525
```
hello Client1 (Yenlik):
client2 at 18:12- hello
client1 at 18:13- hello man
how are you?
client2 at 18:15- how are you?
client1 left the chat...
```console
student$ nc localhost 2525
Welcome to TCP-Chat!
_nnnn_
dGGGGMMb
@p~qp~~qMb
M|@||@) M|
@,----.JM|
JS^\__/ qKL
dZP qKRb
dZP qKKb
fZP SMMb
HZM MMMM
FqM MMMM
__| ". |\dS"qML
| `. | `' \Zq
_) \.___.,| .'
\____ )MMMMMP| .'
`-' `--'
[ENTER YOUR NAME]: Yenlik
[2020-01-20 16:03:43][Yenlik]:hello
[2020-01-20 16:03:46][Yenlik]:How are you?
[2020-01-20 16:04:10][Yenlik]:
Lee has joined our chat...
[2020-01-20 16:04:15][Yenlik]:
[2020-01-20 16:04:32][Lee]:Hi everyone!
[2020-01-20 16:04:32][Yenlik]:
[2020-01-20 16:04:35][Lee]:How are you?
[2020-01-20 16:04:35][Yenlik]:great, and you?
[2020-01-20 16:04:41][Yenlik]:
[2020-01-20 16:04:44][Lee]:good!
[2020-01-20 16:04:44][Yenlik]:
[2020-01-20 16:04:50][Lee]:alright, see ya!
[2020-01-20 16:04:50][Yenlik]:bye-bye!
[2020-01-20 16:04:57][Yenlik]:
Lee has left our chat...
[2020-01-20 16:04:59][Yenlik]:
``` ```
- Client 1 : Client2 (Lee):
```console ```console
stuednt$ ./net-cat 192.168.1.123 8080 student$ nc localhost 2525
wellcome, you are connected Yenliks-MacBook-Air:simpleTCPChat ybokina$ nc localhost 2525
Yenliks-MacBook-Air:simpleTCPChat ybokina$ nc localhost 2525
enter user name : client1 Welcome to TCP-Chat!
your name is client1 _nnnn_
dGGGGMMb
@p~qp~~qMb
M|@||@) M|
@,----.JM|
JS^\__/ qKL
dZP qKRb
dZP qKKb
fZP SMMb
HZM MMMM
FqM MMMM
__| ". |\dS"qML
| `. | `' \Zq
_) \.___.,| .'
\____ )MMMMMP| .'
`-' `--'
[ENTER YOUR NAME]: Lee
[2020-01-20 16:04:15][Lee]:Hi everyone!
[2020-01-20 16:04:32][Lee]:How are you?
[2020-01-20 16:04:35][Lee]:
[2020-01-20 16:04:41][Yenlik]:great, and you?
[2020-01-20 16:04:41][Lee]:good!
[2020-01-20 16:04:44][Lee]:alright, see ya!
[2020-01-20 16:04:50][Lee]:
[2020-01-20 16:04:57][Yenlik]:bye-bye!
[2020-01-20 16:04:57][Lee]:^C
```
client2 joined the chat... ## Bonus
client1 joined the chat...
client2 at 18:12- hello - Terminal UI (you are allowed to use only this package : https://github.com/jroimartin/gocui)
hello man - Logging into the file
client1 at 18:13- hello man - Creating more than 1 group chat
client2 at 18:15- how are you?
^C
```

Loading…
Cancel
Save