2017-10-28 16:10:38 +00:00
|
|
|
# simplFT
|
|
|
|
This project was made for the purpose of me to learn and understand Go better and also for the Computer Networking class
|
|
|
|
that I took in Fall 2017 at UPT.
|
|
|
|
|
|
|
|
The scope of this project is to implement a simple server that handles multiple clients and allows the clients to
|
|
|
|
execute commands on it.
|
|
|
|
|
2017-11-24 20:50:23 +00:00
|
|
|
## Commands
|
|
|
|
|
2017-11-25 14:06:57 +00:00
|
|
|
The server accepts the following commands:
|
|
|
|
|
2017-12-05 13:13:06 +00:00
|
|
|
```
|
|
|
|
get <filename> - Download the requested filename.
|
|
|
|
ls - List the files in the current directory.
|
|
|
|
cd - Changes the directory.
|
|
|
|
clear - Clear the screen.
|
|
|
|
exit - Close the connection with the server.c
|
|
|
|
pic - Returns the ascii art of an image. :-)
|
|
|
|
```
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-25 14:06:57 +00:00
|
|
|
#### Sending commands via netcat
|
|
|
|
|
|
|
|
To grab a file the following command can be send:
|
|
|
|
|
|
|
|
```echo "get file.txt" | nc ip port > lfile.txt```
|
|
|
|
|
|
|
|
If someone wishes to send multiple commands, the following syntax
|
|
|
|
can be used:
|
|
|
|
|
|
|
|
```(echo "get file1.txt" & echo "get file2.txt") | nc ip port > concatenated.txt```
|
|
|
|
|
2017-12-05 13:14:14 +00:00
|
|
|
#### The upload server
|
|
|
|
|
|
|
|
If the upload server is running, the user will be able to put files
|
|
|
|
on the **absoluteServePath**. After the file is uploaded successfully,
|
|
|
|
if the timeout is not reached, the user will get back the filename.
|
|
|
|
|
|
|
|
To send data to the upload server, the following command can be used:
|
|
|
|
|
|
|
|
```nc ip port < gopher.png```
|
|
|
|
|
2017-11-16 09:19:01 +00:00
|
|
|
## Configuration
|
|
|
|
|
2017-11-22 06:49:16 +00:00
|
|
|
The server can be configured via command line flags with the -ConfigPath option,
|
|
|
|
specifying a path to the configuration file.
|
2017-11-16 09:19:01 +00:00
|
|
|
If no configuration file is provided the server will run with the default settings.
|
|
|
|
|
|
|
|
Sample Configuration File:
|
|
|
|
```
|
|
|
|
{
|
2017-11-24 20:37:09 +00:00
|
|
|
"address": "localhost",
|
2017-11-26 21:03:15 +00:00
|
|
|
"port": 8080,
|
2017-11-24 20:37:09 +00:00
|
|
|
"maxDirDepth": 30,
|
2017-11-24 20:50:23 +00:00
|
|
|
"absoluteServePath": "/Users/denis/Dropbox/Pictures/CuteAvatars",
|
|
|
|
"pic": {
|
2017-11-26 21:03:15 +00:00
|
|
|
"color": true,
|
|
|
|
"x": 197,
|
|
|
|
"y": 50
|
|
|
|
},
|
|
|
|
"upload": {
|
|
|
|
"enabled": false,
|
2017-11-30 21:28:18 +00:00
|
|
|
"directory": "upload",
|
2017-11-26 21:03:15 +00:00
|
|
|
"timeout": 5,
|
|
|
|
"address": "localhost",
|
|
|
|
"port": 8081
|
2017-11-24 20:50:23 +00:00
|
|
|
}
|
2017-11-16 09:19:01 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The **config.json** file contains the following settings:
|
|
|
|
|
2017-11-24 21:13:23 +00:00
|
|
|
1. address - The address on which to serve
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-24 21:13:23 +00:00
|
|
|
2. port - The port
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-24 21:13:23 +00:00
|
|
|
3. maxDirDepth - The maximum depth the user can go into directories. A value of 30 means the user can cd into max 30 dirs.
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-24 21:13:23 +00:00
|
|
|
4. absoluteServePath - The path from where to serve the files.
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-26 21:03:15 +00:00
|
|
|
5. pic - The X and Y max size for the pic command. A value of 0 means original size.
|
2017-11-24 20:50:23 +00:00
|
|
|
|
2017-11-26 21:03:15 +00:00
|
|
|
6. upload - Settings for the upload server.
|
2017-11-24 20:50:23 +00:00
|
|
|
If one of the settings are changed, the server will reload the configuration.
|
2017-12-05 13:13:06 +00:00
|
|
|
Except for the absoluteServePath.
|