Skip to content

Commit

Permalink
Update to v1.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
py7hon committed Oct 22, 2021
1 parent 426b632 commit 1833ce1
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 32 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build on Push

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- os: ubuntu-latest
output-name: uup.bin
- os: macOS-latest
output-name: uup.bin
- os: windows-latest
output-name: uup.exe

steps:
- uses: actions/checkout@v1
- uses: DanTup/gh-actions/setup-dart@master
- run: mkdir build
- run: pub get
- run: dart compile exe bin/main.dart -v -o build/${{ matrix.output-name }}
- uses: actions/upload-artifact@v1
with:
name: native-executables
path: build
33 changes: 10 additions & 23 deletions bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,14 @@ void main(List<String> args) async {
if (['download', 'dl', 'd', 'down', '-d', '--download'].contains(command)) {
print('Downloading metadata...');

String hash = args[1];
String ccID = stringToBase64.decode(args[1]);

hash = hash.substring(hash.indexOf('#') + 1);
//ccID = ccID.substring(ccID.indexOf('x') + 2);

if (hash.startsWith(RegExp(r'[0-9]'))) {
print('Unsupported version. Please use the Web UI.');
return;
}

final lengthSep = hash.indexOf('-');

final version = hash.substring(0, lengthSep);
if (version == 'a') {
print('Unsupported version. Please use the Web UI.');
return;
}

hash = hash.substring(lengthSep + 1);

final sep = hash.indexOf('+');

final cID = hash.substring(0, sep);
final key = hash.substring(sep + 1);
final cID = ccID.substring(ccID.indexOf('x-') + 2);
final key = ccID.substring(ccID.indexOf('/#') + 2);
//print(cID);
//print(key);

final dlTask = DownloadTask();

Expand Down Expand Up @@ -118,12 +103,14 @@ void main(List<String> args) async {
}

void exitWithHelp() {
print(greenBold('uup CLI v1'));
print(greenBold('uup CLI v1.9.3'));
print('\n');
print('Encrypted and Fully Decentralized File Share.\nUsing IPFS, Store on Filecoin and Ethereum.');

print('\n');

print(magenta('uup --upload') + ' path/to/file');
print(magenta('uup --download') + ' https://uup.bugs.today/#x-...');
print(magenta('uup --download') + ' a some random string like '+'eC1RbVZaeFFZb010UTloQVhDdTVEamd...');

print('\n');
print(
Expand Down
7 changes: 5 additions & 2 deletions lib/download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DownloadTask {
String key,
) async {
try {
final res = await http.get(getRandomGateway()+'$cID/blob');
final res = await http.get(getRandomGateway()+'$cID/uup');

final cryptParts = base64.decode(key);

Expand Down Expand Up @@ -66,6 +66,9 @@ class DownloadTask {
int i = 0;

totalChunks = metadata['totalchunks'];
final aid = metadata['aid'];

print('Downloading from Anon ID: $aid');

setDLState('Downloading and decrypting chunk 1 of $totalChunks...');

Expand Down Expand Up @@ -101,7 +104,7 @@ class DownloadTask {
while (true) {
try {
final chunkRes = await http.get(
getRandomGateway()+'$chunkcID/blob',
getRandomGateway()+'$chunkcID/uup',
);

final decryptedChunk = await cipher.decrypt(
Expand Down
8 changes: 3 additions & 5 deletions lib/encrypt_block_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ List<String> ipfsGateway = [
'https://ipfs.io/ipfs/', // FAST and CORS
'https://cloudflare-ipfs.com/ipfs/', // FAST and CORS, Video Stream not supported
'https://ipfs.fleek.co/ipfs/', // FAST and CORS
'https://crustwebsites.net/ipfs/', // FAST and CORS
'https://3cloud.ee/ipfs/', // FAST and CORS
'https://dweb.link/ipfs/', // FAST and CORS
'https://bluelight.link/ipfs/', // FAST and CORS
'https://ipfs.trusti.id/ipfs/', // FAST and CORS
'https://ipfs.eu.org/ipfs/', // FAST and CORS
];

String getRandomGateway() {
Expand Down Expand Up @@ -67,7 +65,7 @@ class EncryptionUploadTask {
print('Total chunks: $totalChunks');

final uploaderFileId = Uuid().v4();
print('Upload ID: $uploaderFileId');
print('Your Anon Upload ID: $uploaderFileId');

setState('Encrypting and uploading file... (Chunk 1 of $totalChunks)');

Expand Down Expand Up @@ -134,7 +132,7 @@ class EncryptionUploadTask {
'file',
byteStream,
chunk.length,
filename: 'blob',
filename: 'uup',
contentType: MediaType('application', 'octet-stream'),
);
request.headers['authorization'] = 'Bearer ${API.KEY}';
Expand Down
10 changes: 8 additions & 2 deletions lib/upload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:cryptography/cryptography.dart';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as p;
import 'package:mime_type/mime_type.dart';
import 'package:uuid/uuid.dart';
import 'package:uup_cli/ansi_pens.dart';
import 'package:uup_cli/encrypt_block_stream.dart';
import 'package:uup_cli/const.dart';
Expand All @@ -25,8 +26,11 @@ void startEncryptAndUpload(
final nonce = Nonce.randomBytes(16);

final totalChunks = (file.lengthSync() / (chunkSize + 32)).abs().toInt() + 1;

final uploaderFileId = Uuid().v4();

final metadata = {
'aid': uploaderFileId,
'filename': p.basename(file.path),
'type': mime(file.path),
'chunksize': chunkSize,
Expand Down Expand Up @@ -75,9 +79,11 @@ void startEncryptAndUpload(
final secret =
base64.encode([...(await secretKey.extract()), ...nonce.bytes]);

final link = 'https://uup.bugs.today/#x-$cID+$secret';
final link = stringToBase64.encode('x-$cID/#$secret');

print('Secure Download Link for ${greenBold(metadata['filename'])}: $link');
print('Secure Download Link for ${greenBold(metadata['filename'])}:');
print('\nCLI: $link');
print('\nWeb: https://uup.bugs.today/x-$cID/#$secret');
}

Stream<List<int>> getStreamOfIOFile(Stream<List<int>> stream) async* {
Expand Down

0 comments on commit 1833ce1

Please sign in to comment.