mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-27 01:51:30 +02:00
Files move directly between peers over the overlay, with no server in the path. The receiver listens on the WireGuard address only, so the port is unreachable from outside the tunnel, and every offer is matched to a known peer before anything is read. Consent is the default: an offer carries metadata alone, and no payload moves until the receiver accepts. Policy is per profile and device-local — off, ask, or auto-accept, with per-sender exceptions on top. Policy and history live in the profile's preferences, so removing a profile takes its file drop state with it. Transfers interrupted by a restart are settled on load; nothing survives to finish them, and left alone they would sit in the log as permanently pending. The Android bindings pull payload bytes through a chunk-returning stream: gomobile copies a []byte argument into a fresh Java array and never copies it back, so a fill-my-buffer method would hand back the right length with no data.
25 lines
893 B
TypeScript
25 lines
893 B
TypeScript
import { createContext, useContext, useMemo, useState, type ReactNode } from "react";
|
|
|
|
export type NavSection = "peers" | "networks" | "files";
|
|
|
|
type NavSectionContextValue = {
|
|
section: NavSection;
|
|
setSection: (s: NavSection) => void;
|
|
};
|
|
|
|
const NavSectionContext = createContext<NavSectionContextValue | null>(null);
|
|
|
|
export const useNavSection = (): NavSectionContextValue => {
|
|
const ctx = useContext(NavSectionContext);
|
|
if (!ctx) {
|
|
throw new Error("useNavSection must be used inside NavSectionProvider");
|
|
}
|
|
return ctx;
|
|
};
|
|
|
|
export const NavSectionProvider = ({ children }: { children: ReactNode }) => {
|
|
const [section, setSection] = useState<NavSection>("peers");
|
|
const value = useMemo<NavSectionContextValue>(() => ({ section, setSection }), [section]);
|
|
return <NavSectionContext.Provider value={value}>{children}</NavSectionContext.Provider>;
|
|
};
|