Browse Source

net-cat

pull/445/head
lee 4 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
##### Try running `"./net-cat -p 8080"`.
###### Is the server listening for connections?
##### Try running `"./TCPChat"`.
###### 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?
##### 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>"`.
###### Does all clients connect to the server with [UDP](https://www.privateinternetaccess.com/blog/2018/12/tcp-vs-udp-understanding-the-difference/) connection?
##### Try creating a server and 2 Clients.
###### Did server respond you with linux logo and asked for the name?
##### Try creating a server and 2 Clients.
###### 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?
##### 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?
###### Does the project present go routines?
###### Does the project use channels or mutexe?
##### Are the students using just the allowed functions?
#### General
###### +Can the Clients change their names?
###### +Is the chat group informed if a Client changes his name?
###### +Does the server produce logs about Clients activities?
###### +Does the server logs saved into a file?
###### +Is there more NetCat flags implemented?
###### +Does the project present a Terminal UI using JUST this package : https://github.com/jroimartin/gocui?
#### 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.
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`.
- Each Client must have an user name.
- TCP connection between server and multiple clients (relation of 1 to many).
- A name requirement to the client.
- Control connections quantity.
- 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 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.
- 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 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 :
@ -52,70 +55,163 @@ This project will help you learn about :
- TCP/UDP socket
- [Channels](https://tour.golang.org/concurrency/2)
- [Goroutines](https://tour.golang.org/concurrency/1)
- Mutexes
- 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
- Your project must be written in **Go**.
- Your project must use TCP or UDP.
- 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.
- Your project must be written in **Go**
- Start TCP server, listen and accept connections
- Your project must have Go-routines
- Your project must have channels or Mutexes
- 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
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
student$ ./net-cat -p 8080
listening on port 8080....
student$ nc $IP $port
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
student$ ./net-cat 192.168.1.123 8080
welcome, you are connected
student$ nc $IP $port
```
enter user name : client2
your name is client2
Server:
client2 joined the chat...
client1 joined the chat...
```console
student$ ./TCPChat 2525
Listening on the port :2525
```
hello
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...
Client1 (Yenlik):
```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
stuednt$ ./net-cat 192.168.1.123 8080
wellcome, you are connected
enter user name : client1
your name is client1
student$ nc localhost 2525
Yenliks-MacBook-Air:simpleTCPChat ybokina$ nc localhost 2525
Yenliks-MacBook-Air:simpleTCPChat ybokina$ 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]: 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...
client1 joined the chat...
## Bonus
client2 at 18:12- hello
hello man
client1 at 18:13- hello man
client2 at 18:15- how are you?
^C
```
- Terminal UI (you are allowed to use only this package : https://github.com/jroimartin/gocui)
- Logging into the file
- Creating more than 1 group chat

Loading…
Cancel
Save