Coder Social home page Coder Social logo

grpc-file-transfer's Introduction

grpc-file-transfer

SSL secured file transfer gRPC client and server written in Python language.

Project structure

|-- cert - SSL certificates
|   `-- generate.sh - bash script for generating SSL certificates
|-- client - package with gRPC file transfer client code
|   |-- client.py
|   |-- __init__.py
|   `-- main.py
|-- protos - folder with gRPC interface for file transfer service
|   |-- file.proto
|   `-- __init__.py
|-- README.md
|-- requirements.txt
|-- resources
|   |-- client - example folder where files can be downloaded
|   `-- server - example folder for example files which can be downloaded
|       |-- test_file2.txt
|       `-- test_file.txt
`-- server - package with gRPC file transfer server code
    |-- __init__.py
    |-- main.py
    `-- server.py

Prerequisites

  • Python3
  • pip3
  • OpenSSL

Example usage

  1. Prepare project:
    • Go to project root directory.
    • Use the package manager for Python to install dependencies.
      pip3 install -r requirements.txt
    • Grant the owner of cert/generate.sh file execution permissions.
      chmod u+x cert/generate.sh
    • Generate certificate.
      Warning: Don't use such created certificates for production environment.
      cert/generate.sh /CN=localhost
      CN (Common Name) must match server name that you connect to with the client. In this example we will use localhost.
  2. Lauch gRPC file transfer server in first console:
    python3 -m server.main -i localhost -p 5000 -w 2 -d resources/server -priv cert/server.key -cert cert/server.crt
  3. Lauch gRPC file transfer client in second console:
    • list available files to download from server
      python3 -m client.main -i localhost -p 5000 -c cert/server.crt list
    • download test_file.txt file from server to resources/client directory:
      python3 -m client.main -i localhost -p 5000 -c cert/server.crt download -d resources/client -f test_file.txt

Description of client and server arguments

  • server
usage: main.py [-h] -i IP_ADRESS -p PORT -w MAX_WORKERS -d FILES_DIRECTORY
               -priv PRIVATE_KEY_FILE -cert CERT_FILE

gRPC file transfer server

optional arguments:
  -h, --help            show this help message and exit
  -i IP_ADRESS, --ip_adress IP_ADRESS
                        IP address for server
  -p PORT, --port PORT  port address for server
  -w MAX_WORKERS, --max_workers MAX_WORKERS
                        maximum worker threads for server
  -d FILES_DIRECTORY, --files_directory FILES_DIRECTORY
                        directory containing files
  -priv PRIVATE_KEY_FILE, --private_key_file PRIVATE_KEY_FILE
                        private key file path
  -cert CERT_FILE, --cert_file CERT_FILE
                        certificate file path
  • client
usage: main.py [-h] -i IP_ADRESS -p PORT -c CERT_FILE {download,list} ...

gRPC file transfer client

positional arguments:
  {download,list}       client possible actions
    download            download file from server
    list                list files on server

optional arguments:
  -h, --help            show this help message and exit
  -i IP_ADRESS, --ip_adress IP_ADRESS
                        IP address of server
  -p PORT, --port PORT  port address of server
  -c CERT_FILE, --cert_file CERT_FILE
                        certificate file path

If you use download action you must provide below paramaters:
optional arguments:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        where to save files
  -f FILE, --file FILE  file name to download

grpc-file-transfer's People

Contributors

r-sitko avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.