Skip to content

Commit

Permalink
Merge pull request #173 from StarfilesFileSharing/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
QuixThe2nd authored Nov 16, 2024
2 parents 9e33945 + 0df8d70 commit 575f58a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@starfiles/hydrafiles",
"version": "0.9.2",
"version": "0.9.3",
"description": "The (P2P) web privacy layer.",
"main": "src/hydrafiles.ts",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion docs/2. Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Using Hydrafiles is simple in your project is simple. Hydrafiles is a JavaScript library that can be imported into your project. The library is compatible with Deno, Node.js, and the browser.

## Install
## Import

To get started, import the library into your project. You can find the latest release [here](https://github.com/StarfilesFileSharing/hydrafiles/releases). Or import the library directly from any Hydrafiles peer (e.g.
[here](https://hydrafiles.com/hydrafiles-web.esm.js)).
Expand Down
2 changes: 1 addition & 1 deletion docs/4. Contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CDNs cache files which makes download times faster and lowers server load. CDNs

**Option A: Running a Client** improves availability as your client talks to all peers instead of relying on just one. Your client also verifies that files haven't been tampered with before forwarding them.

**Option B: Running a Reverse Proxy** is cheaper but less safe as file integrity can't be verified. It is not recommended to rely on a reverse-proxied peer as am exit point.
**Option B: Running a Reverse Proxy** is cheaper but less safe as file integrity can't be verified. It is not recommended to rely on a reverse-proxied peer as an exit point.

To set up the reverse proxy, first choose a Hydrafiles IP from an HTTP node you can find [here](/dashboard.html). Then configure
[Nginx](https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-on-ubuntu-22-04), [Caddy](https://caddyserver.com/docs/quick-starts/reverse-proxy), or similar software to point port 80 to the IP.
Expand Down
2 changes: 1 addition & 1 deletion docs/5. Web Nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The browser environment is sandboxed, forcing Hydrafiles to implement some **hac
The core differences include:

- **No Ports:** Before v0.6, Hydrafiles ran purely on HTTP. All peers were required to run an HTTP server to contribute to the network (seed). As of v0.6, Hydrafiles now supports WebRTC. Hydrafiles full nodes still support HTTP, but both
now support WebRTC. This allows for web nodes to contribute to the network (and anonymity-set). Full nodes now also host a WebSocket room to in-house signalling.
now support WebRTC. This allows for web nodes to contribute to the network (and anonymity-set). Full nodes now also host a WebSocket room to handle in-house signalling.
- **No SQLite:** Hydrafiles uses SQLite. SQLite is not supported in browsers. There is also no modern implementation of SQL in the web either. Web nodes now use IndexedDB as the database.
- **No File System:** Websites are unable to access your filesystem. Modern browsers are starting to support FileSystem API, which solves this. But [support is lackluster](https://caniuse.com/?search=showDirectoryPicker) with only
chromium-based desktop browsers supporting it. To solve this, we have implemented a virtual file system. Web nodes wraps IndexedDB to make it act like a file system, treating each file write as a row insert, and file read as a row read.
Expand Down
2 changes: 1 addition & 1 deletion docs/8. Hash Counting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ To fix diminishing returns after a lot of hashes have been generated, we can imp

## When/Why do peers vote?

Peers can vote for files they believe are important at any time and as many times as they want. This allows us to rank files based on whate the network believes is important.
Peers can vote for files they believe are important at any time and as many times as they want. This allows us to rank files based on what the network believes is important.
24 changes: 14 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ class Utils {
const os = await import("https://deno.land/[email protected]/node/os.ts");
return os.freemem() > (fileSize + this._config.memoryThreshold);
};
static promiseWithTimeout = async <T>(promise: Promise<T>, timeoutDuration: number): Promise<T | ErrorTimeout> =>
await Promise.race([
promise,
new Promise<never>((_resolve, reject) =>
setTimeout(
() => reject(new ErrorTimeout()),
timeoutDuration,
)
),
]);

static async promiseWithTimeout<T>(promise: Promise<T>, timeoutDuration: number): Promise<T | ErrorTimeout> {
try {
return await Promise.race<T | ErrorTimeout>([
promise,
new Promise((_, reject) => {
setTimeout(() => reject(new ErrorTimeout()), timeoutDuration);
}),
]);
} catch (error) {
if (error instanceof ErrorTimeout) return error;
else throw error;
}
}

static estimateHops = (signalStrength: number): { hop: number | null; certainty: number } => {
const hopData = [
Expand Down

0 comments on commit 575f58a

Please sign in to comment.