Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from m-cat/add-encryption
Browse files Browse the repository at this point in the history
Add encryption
  • Loading branch information
MSevey authored Jul 23, 2020
2 parents 8d0214b + cab3487 commit c8153ac
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 50 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
- name: Build
run: go build -v .
run: make build
- name: Lint script
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.27.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.29.0
python -m pip install --upgrade pip
pip install codespell
go get -u gitlab.com/NebulousLabs/analyze
go get -u -d ./...
./bin/golangci-lint run -c .golangci.yml ./...
export PATH=${PATH}:`go env GOPATH`/bin
make lint
make lint-analyze
make markdown-spellcheck
make test
test:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# User Generated Content
cover/
release/
skynet

# Git
.git
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ spellcheck: markdown-spellcheck
staticcheck:
staticcheck $(pkgs)

build:
go build -v $(pkgs)

# release builds and installs release binaries.
release:
go install -tags='netgo' -ldflags='-s -w $(ldflags)' $(pkgs)
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skynet-cli

![](https://github.com/NebulousLabs/skynet-cli/workflows/Go/badge.svg)

skynet-cli is a lightweight cli to interact with [Skynet](https://siasky.net).
skynet-cli is a lightweight CLI to interact with [Skynet](https://siasky.net).

Skynet is the decentralized CDN and file sharing platform for devs and the
storage foundation for a Free Internet!
Expand All @@ -10,16 +11,22 @@ storage foundation for a Free Internet!

skynet-cli is designed to be simple and easy to use, just like Skynet.

Uploading a file is a simple as using the following command.
```
Uploading a file or directory is a simple as using the following command:

```shell
skynet upload [source path]
```

This will return a `skylink`, which then in turn can be used to download the
file with the following command.
```
file with the following command:

```shell
skynet download [skylink] [destination]
```

To learn about addition commands you can always use the `-h` flag or check out
the [documentation](./docs).
## Documentation

For comprehensive documentation complete with examples, please see [the Skynet SDK docs](https://nebulouslabs.github.io/skynet-docs/?shell--cli#introduction).

To learn about additional commands you can always use the `-h` flag or check out
the [documentation](./doc).
57 changes: 47 additions & 10 deletions cmd/skynet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"gitlab.com/NebulousLabs/errors"
)

const (
Expand All @@ -32,16 +33,19 @@ var (
// skynet commands
generateDocs bool

// Skynet Flags
// Common Skynet Flags
//
// skynetPortal will define a Skynet Portal to use instead of the default.
skynetPortal string

// endpointPath is the relative URL path of the endpoint.
endpointPath string

// customUserAgent is the custom user agent to use.
customUserAgent string

// Upload Flags
//
// portalUploadPath is the relative URL path of the upload endpoint.
portalUploadPath string

// portalFileFieldName is the fieldName for files on the portal.
portalFileFieldName string

Expand All @@ -52,24 +56,47 @@ var (
// customFilename is the custom filename to use for the upload. If this is
// empty, the filename of the file being uploaded will be used by default.
customFilename string

// customDirname is the custom directory filename to use for the upload. If
// this is empty, the name of the directory being uploaded will be used by
// default.
customDirname string

// uploadSkykeyName is the name of the skykey used to encrypt the upload.
uploadSkykeyName string

// uploadSkykeyID is the ID of the skykey used to encrypt the upload.
uploadSkykeyID string

// Download Flags
//
// downloadSkykeyName is the name of the skykey used to decrypt the upload.
downloadSkykeyName string

// downloadSkykeyID is the ID of the skykey used to decrypt the upload.
downloadSkykeyID string
)

// copyDocFile will copy the top level auto generated doc file into a README for
// /doc
func copyDocFile() error {
func copyDocFile() (err error) {
// Open the main doc file
source, err := os.Open(mainDocFile)
if err != nil {
return err
}
defer source.Close()
defer func() {
err = errors.Compose(err, source.Close())
}()

// Open the README file
destination, err := os.Create(docREADMEFile)
if err != nil {
return err
}
defer destination.Close()
defer func() {
err = errors.Compose(err, destination.Close())
}()

// Copy the main doc file into the README
_, err = io.Copy(destination, source)
Expand Down Expand Up @@ -112,15 +139,25 @@ on top of Sia.`,
}

// Add Skynet Commands
rootCmd.AddCommand(skynetBlacklistCmd, skynetConvertCmd, skynetDownloadCmd, skynetLsCmd, skynetPinCmd, skynetUnpinCmd, skynetUploadCmd)
rootCmd.AddCommand(skynetBlacklistCmd, skynetConvertCmd, skynetDownloadCmd, skynetLsCmd, skynetPinCmd, skynetSkykeyCmd, skynetUnpinCmd, skynetUploadCmd)
skynetSkykeyCmd.AddCommand(skynetSkykeyAddCmd, skynetSkykeyCreateCmd, skynetSkykeyGetCmd, skynetSkykeyGetSkykeysCmd)
skynetSkykeyGetCmd.AddCommand(skynetSkykeyGetIDCmd, skynetSkykeyGetNameCmd)

// Add Flags
// Add flags.
rootCmd.Flags().BoolVarP(&generateDocs, "", "d", false, "Generate the docs for skynet")
rootCmd.PersistentFlags().StringVar(&skynetPortal, "portal", "", "Use a Skynet portal other than the default")
skynetUploadCmd.Flags().StringVar(&portalUploadPath, "upload-path", "", "Relative URL path of the upload endpoint")
rootCmd.PersistentFlags().StringVar(&endpointPath, "endpoint-path", "", "Relative URL path of the endpoint to use")
rootCmd.PersistentFlags().StringVar(&customUserAgent, "custom-user-agent", "", "Custom user agent to use")
// Upload flags.
skynetUploadCmd.Flags().StringVar(&portalFileFieldName, "file-field-name", "", "Defines the fieldName for the files on the portal")
skynetUploadCmd.Flags().StringVar(&portalDirectoryFileFieldName, "directory-field-name", "", "Defines the fieldName for the directory files on the portal")
skynetUploadCmd.Flags().StringVar(&customFilename, "filename", "", "Custom filename for the uploaded file")
skynetUploadCmd.Flags().StringVar(&customDirname, "dirname", "", "Custom dirname for the uploaded directory")
skynetUploadCmd.Flags().StringVar(&uploadSkykeyName, "skykey-name", "", "Name of the skykey on the portal used to encrypt the upload")
skynetUploadCmd.Flags().StringVar(&uploadSkykeyID, "skykey-id", "", "ID of the skykey on the portal used to encrypt the upload")
// Download flags.
skynetDownloadCmd.Flags().StringVar(&downloadSkykeyName, "skykey-name", "", "Name of the skykey on the portal used to decrypt the download")
skynetDownloadCmd.Flags().StringVar(&downloadSkykeyID, "skykey-id", "", "ID of the skykey on the portal used to decrypt the download")

// run
if err := rootCmd.Execute(); err != nil {
Expand Down
Loading

0 comments on commit c8153ac

Please sign in to comment.