Client-Server tcp-based file transfer application in GoLang

Клиент-серверный файловый сервис на базе протокола TCP

Клиент client.go шифрует свои файлы алгоритмом AES с режимом CBC и помещает их на сервер server.go. Также, скачивает с сервера и расшифровывает.

Порядок работы:

  • Пользователь запускает client, при успешном соединении клиента с сервером вводит свой логин/пароль для входа на сервер. Появляется строка приглашения ftp>.
  • Для копирования файла на сервер вводит upload <имя своего файла>, затем пароль (не меньше 5ти символов).
  • Происходит шифрование файла алгоритмом AES с режимом CBC, затем закачка файла на сервер. Сервер сообщает новое имя файла в формате UUID.
  • Пользователь может просмотреть список файлов на сервере при помощи ls.
  • Пользователь вводит имя (на сервере все имена файлов в формате UUID) нужного ему на сервере файла upload <имя файла на сервере>, затем пароль.
  • Происходит передача файла с сервера на клиентскую часть, расшифровка и сохранение с серверным именем.

Список команд:

  • upload upload file from filestore/clientDir to filestore
  • download download file from server
  • ls list files on server
  • close/exit close connection

Config and run

Fill credential.json your usernames/passwords. Open two terminals on project folder 1st terminal:

go run cmd/server.go

2nd terminal:

#Multiple clients can be attached 
go run cmd/client/client.go

Code review:

Основной проблемой при передаче данных по сокету являлось разделение потока байтов на команды (string) и сам файл ([]byte). net.Conn, к сожалению, имеет очень ограниченный набор команд. В частности, не хватает io.ReadRune. Поэтому выходом стало скачивание потока побайтно io.CopyN(,,1) с сравнением каждого байта с '\n'. До '\n' передается размер файла в байтах, после '\n' скачиватся этот размер файла (client/getfile.go).

Обнаружилось, что для блочного шифрования файла его исходный разиер в байтах должен быть кратным 16. Поэтому выполнено дописывание в конец файла \x01 и затем нулей \x00, соответственно которые убираются при дешифровке (client/crypto.go).

Проект выполнен встроенным набором Golang без сторонних библиотек, кроме получения UUID при помощи google/uuid.

Асинхронность достигается выделением каждого

Make sure to allow traffic to the port specified on your VPC firewall.

Thanks for samples bisakhmondal/FTP-Go, kdama/gopl, fclairamb/ftpserver.

Similar Resources

“Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server!

Dear Port80 About The Project: “Dear Port80” is a zero-config TCP proxy server that hides SSH connection behind a HTTP server! +---------------------

Jun 29, 2022

A TCP socket based chat server implemented using Go

Go Chat Server A better TCP socket chat server implemented using Go Connecting nc localhost 5000 Docker Build the container image docker build -t grub

Oct 16, 2021

📦 Command line peer-to-peer data transfer tool based on libp2p.

pcp - Peer Copy Command line peer-to-peer data transfer tool based on libp2p. Table of Contents Motivation Project Status How does it work? Usage Inst

Jan 5, 2023

HTTP based Tree-shaped Peer2Peer blob transfer proxy, distributing images or blob data.

HTTP based Tree-shaped Peer2Peer blob transfer proxy, distributing images or blob data.

DadiP2P DadiP2P is an accelerator that uses P2P protocol to speed up HTTP file download, usually use for docker image layer download. The key features

Nov 24, 2022

golang tcp server

TCPServer Package tcp_server created to help build TCP servers faster. Install package go get -u github.com/firstrow/tcp_server Usage: NOTICE: OnNewMe

Dec 28, 2022

A socks5 server(tcp/udp) written in golang.

socks5-server A socks5 server(tcp/udp) written in golang. Usage Usage of /main: -l string local address (default "127.0.0.1:1080") -p stri

Nov 20, 2022

Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021

A TCP Server Framework with graceful shutdown, custom protocol.

xtcp A TCP Server Framework with graceful shutdown,custom protocol. Usage Define your protocol format: Before create server and client, you need defin

Dec 7, 2022

TCP echo server

Echo v0.1.2 What TCP Echo server. RFC862 implementation. Usage of package package main import ( "context" "github.com/boratanrikulu/echo" ) func

Jul 26, 2021
Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp conne

May 27, 2021
Tcp chat go - Create tcp chat in golang

TCP chat in GO libs Go net package and goroutines and channels tcp tcp or transm

Feb 5, 2022
TCP based Client/Server chat CLI in Go
 TCP based Client/Server chat CLI in Go

TCP based Client/Server chat CLI in Go Written in Go, this is a simple implementation of a TCP server that can detect new clients connecting and disco

Jul 27, 2022
TcpRoute , TCP 层的路由器。对于 TCP 连接自动从多个线路(电信、联通、移动)、多个域名解析结果中选择最优线路。

TcpRoute2 TcpRoute , TCP 层的路由器。对于 TCP 连接自动从多个线路(允许任意嵌套)、多个域名解析结果中选择最优线路。 TcpRoute 使用激进的选路策略,对 DNS 解析获得的多个IP同时尝试连接,同时使用多个线路进行连接,最终使用最快建立的连接。支持 TcpRoute

Dec 27, 2022
TCP output for beats to send events over TCP socket.

beats-tcp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

Aug 25, 2022
Golang pow implementation client <-> server over UDP and TCP protocols
Golang pow implementation client <-> server over UDP and TCP protocols

Client <-> server over UDP and TCP pow protocol Denial-of-Service-attacks are a typical situation when providing services over a network. A method for

Jan 13, 2022
EasyTCP is a light-weight and less painful TCP server framework written in Go (Golang) based on the standard net package.

EasyTCP is a light-weight TCP framework written in Go (Golang), built with message router. EasyTCP helps you build a TCP server easily fast and less painful.

Jan 7, 2023
Make TCP connection storm between server and client for benchmarking network stuff

Make TCP connection storm between server and client for benchmarking network stuff

Nov 14, 2021
Client - Server TCP Chat For String Messages And Random Files

GoChat Client - Server TCP Chat For String Messages And Random Files GoChat is a chat for string messages and random files using Golorem by Derek A. R

Sep 29, 2021
Simple TCP proxy to visualise NATS client/server traffic
Simple TCP proxy to visualise NATS client/server traffic

NATS uses a simple publish/subscribe style plain-text protocol to communicate between a NATS Server and its clients. Whilst this connection should remain opaque to the user, it can be quite handy to see the data being passed from time to time - this tool does just that (it also saves me loading Wireshark and filtering the NATS traffic).

Jan 15, 2022