### Example geph5-client Configuration Source: https://github.com/geph-official/geph5/blob/master/binaries/geph5-client/README.md This is an example YAML configuration file for the geph5-client. It shows how to set up local proxy listeners, broker connection details, and credentials. ```yaml socks5_listen: 127.0.0.1:9910 http_proxy_listen: 127.0.0.1:9911 pac_listen: 127.0.0.1:9912 control_listen: 127.0.0.1:9913 exit_constraint: auto bridge_mode: auto cache: /var/cache/geph5-client broker: direct: "https://broker.geph.io/" broker_keys: master: "deadbeef..." mizaru_free: "deadbeef..." mizaru_plus: "deadbeef..." vpn: false spoof_dns: false passthrough_china: false credentials: legacy_username_password: username: "user" password: "pass" ``` -------------------------------- ### User Authentication Credentials Example Source: https://github.com/geph-official/geph5/blob/master/PRIVACY.md Illustrates the structure of stored user authentication credentials, including username, password hash, and timestamps. Note the use of Argon2 for password hashing. ```sql id | username | pwdhash | createtime | last_login ----+----------+----------+----------------------------+---------------------------- 51 | pwtest | $arg... | 2019-12-29 12:34:28.72295 | 2022-12-23 17:58:30.9346 ``` -------------------------------- ### Example geph5-exit Configuration Source: https://github.com/geph-official/geph5/blob/master/binaries/geph5-exit/README.md This YAML configuration specifies keys for signing descriptors, connection details for the broker, networking settings like listening addresses, and country information. It also includes rate limits and whitelisted ports. ```yaml signing_secret: /etc/geph5/exit/signing.key broker: url: https://broker.geph.io/ auth_token: my-secret c2e_listen: 0.0.0.0:9002 b2e_listen: 0.0.0.0:9003 ip_addr: 203.0.113.5 country: USA city: NYC metadata: allowed_levels: [plus] category: [core] country_blacklist: [] free_ratelimit: 300 plus_ratelimit: 30000 total_ratelimit: 125000 free_port_whitelist: [20,21,43,53,79,80,81,88,110,143,220,389,443,464,531,543,544,554,636,706,749,873,902,903,904,981,989,990,991,992,993,995,1194,1220,1293,1500,1533,1677,1723,1755,1863,2083,2086,2087,2095,2096,2102,2103,2104,3690,4321,4643,5050,5190,5222,5223,5228,8008,8074,8082,8087,8088,8332,8333,8443,8888,9418,10000,11371,19294,19638,50002,64738] task_limit: 1000000 ipv6_subnet: "2001:db8::/64" ipv6_pool_size: 100 ``` -------------------------------- ### Geph5 Broker Configuration Example Source: https://github.com/geph-official/geph5/blob/master/binaries/geph5-broker/README.md This YAML configuration defines essential parameters for the geph5-broker, including network listeners, cryptographic key paths, database connection details, and authentication tokens. Adjust these settings to match your deployment environment. ```yaml listen: 0.0.0.0:9000 tcp_listen: 0.0.0.0:9001 master_secret: /etc/geph5/broker/master.bin mizaru_keys: /etc/geph5/broker/mizaru postgres_url: postgres://geph:password@localhost/geph bridge_token: bridge_secret exit_token: exit_secret puzzle_difficulty: 24 payment_url: https://web-backend.geph.io/rpc payment_support_secret: support-secret ``` -------------------------------- ### Displaying User Authentication Credentials Source: https://github.com/geph-official/geph5/wiki/Policies-and-terms This example shows the structure of user authentication data stored by Geph, including user ID, secret, creation time, and last login time. This data is used for authentication purposes. ```text id | secret | createtime | last_login ----+--------------+---------+----------------------------+---------------------------- 51 | 124987198573 | 2019-12-29 12:34:28.72295 | 2022-12-23 17:58:30.9346 ``` -------------------------------- ### Grafana Query: RPC request rate Source: https://github.com/geph-official/geph5/blob/master/STATS.md Example SQL query for Grafana to show the RPC request rate from a timer table. It utilizes `metric_rate()` with 'count' as the field and groups by time and method. ```sql -- RPC request rate from the timer table SELECT "time", tags->>'method' AS method, value AS rps FROM metric_rate('broker_rpc_calls', $__timeFrom(), $__timeTo(), interval '$__interval', 'count') ORDER BY 1; ``` -------------------------------- ### Displaying Payment Transaction History Source: https://github.com/geph-official/geph5/wiki/Policies-and-terms This example illustrates the format of transaction history stored for payment processing. It includes invoice ID, duration in days, amount, creation and payment timestamps, user ID, payment method, and metadata. This is used to track payment activity. ```text invoice_id | days | amount | created_at | paid_at | user_id | pay_method | metadata ------------+------+--------+---------------------+---------------------+---------+------------+------------- 74 | 30 | 500 | 2022-07-17 12:07:18 | 2022-07-17 12:10:18 | 3 | stripe | Plus ``` -------------------------------- ### Grafana Query: Per-exit throughput Source: https://github.com/geph-official/geph5/blob/master/STATS.md Example SQL query for Grafana to display per-exit throughput in bits per second (bps). It uses the `metric()` function and transforms kilobytes per second to bits per second. ```sql -- per-exit throughput (kbps is kilobytes/s, ×8000 = bits/s) SELECT "time", tags->>'exit' AS exit, value * 8000 AS bps FROM metric('kbps', $__timeFrom(), $__timeTo(), interval '$__interval') ORDER BY 1; ``` -------------------------------- ### Grafana Query: Bridged traffic rate Source: https://github.com/geph-official/geph5/blob/master/STATS.md Example SQL query for Grafana to calculate the bridged traffic rate per pool in bits per second. It uses `metric_rate()` and groups results by time and pool. ```sql -- bridged traffic by pool, as bits/s (see "Rates" below for why metric_rate) SELECT "time", tags->>'pool' AS pool, sum(value) * 8 AS bps FROM metric_rate('bridge_bytes', $__timeFrom(), $__timeTo(), interval '$__interval') GROUP BY 1, 2 ORDER BY 1; ``` -------------------------------- ### Apply SQL Schema for Metrics Source: https://github.com/geph-official/geph5/blob/master/STATS.md Apply the idempotent SQL schema to set up the metrics database. This script is used to create tables and manage the metrics schema in PostgreSQL. ```bash psql "$POSTGRES_URL" -f metrics.sql ``` -------------------------------- ### metric_rate() function Source: https://github.com/geph-official/geph5/blob/master/STATS.md The `metric_rate()` function is specifically designed for calculating per-second rates (e.g., throughput, RPS). It ensures accurate rate calculation by dividing the sum of each bucket by its full width and only returning complete buckets, avoiding artifacts from partial buckets. ```APIDOC ## metric_rate(name text, from timestamptz, to timestamptz, bucket interval, field text DEFAULT 'value') **Returns:** TABLE ("time" timestamptz, tags jsonb, value double precision) **Description:** Calculates per-second rates for metrics. This function is preferred over manual calculation using `metric(..., 'sum') / interval` because it correctly handles bucket widths and only returns complete data points, preventing inaccuracies from partial buckets. The results are in value-per-second. **Parameters:** - **name** (text): The name of the metric to query. - **from** (timestamptz): The start timestamp for the query. - **to** (timestamptz): The end timestamp for the query. - **bucket interval** (interval): The desired bucket size for aggregation. - **field** (text, optional, default 'value'): The specific field to use for rate calculation (e.g., 'count' for event rates). ### Example Usage (Postgres datasource for Grafana): ```sql -- bridged traffic by pool, as bits/s SELECT "time", tags->>'pool' AS pool, sum(value) * 8 AS bps FROM metric_rate('bridge_bytes', $__timeFrom(), $__timeTo(), interval '$__interval') GROUP BY 1, 2 ORDER BY 1; -- RPC request rate from the timer table SELECT "time", tags->>'method' AS method, value AS rps FROM metric_rate('broker_rpc_calls', $__timeFrom(), $__timeTo(), interval '$__interval', 'count') ORDER BY 1; ``` **Note:** For per-second rates, multiply the returned `value` by 8 to convert bytes to bits. ``` -------------------------------- ### SQL Function Signature: metric_rate() Source: https://github.com/geph-official/geph5/blob/master/STATS.md Defines the signature for the `metric_rate()` SQL function, which calculates per-second rates. It returns only complete buckets within the specified time range. ```sql metric_rate(name text, from timestamptz, to timestamptz, bucket interval, field text DEFAULT 'value') RETURNS TABLE ("time" timestamptz, tags jsonb, value double precision) ``` -------------------------------- ### Emit Stats from Broker Source: https://github.com/geph-official/geph5/blob/master/STATS.md The broker emits stats directly to a local Telegraf instance via UDP. Ensure STATS_SINK is initialized and the statsd_addr is configured. ```rust use geph5_stats::StatEvent; if let Some(sink) = STATS_SINK.as_ref() { sink.send_one(&StatEvent::timer_ms("broker_rpc_calls", &[("method", method)], ms)); sink.send_many(&events); // batches into as few UDP datagrams as possible } ``` -------------------------------- ### SQL Function Signature: metric() Source: https://github.com/geph-official/geph5/blob/master/STATS.md Defines the signature for the `metric()` SQL function used for querying time-series data. It supports aggregation and field selection. ```sql metric(name text, from timestamptz, to timestamptz, bucket interval, agg text DEFAULT 'avg', -- avg | sum | max | min field text DEFAULT 'value') -- e.g. 'mean'/'count' for timer tables RETURNS TABLE ("time" timestamptz, tags jsonb, value double precision) ``` -------------------------------- ### Emit Stats from Exits Source: https://github.com/geph-official/geph5/blob/master/STATS.md Exits send a batch of gauges to the broker via the `report_stats` RPC. This requires authentication using a MAC scheme. ```rust // exits: send a batch of gauges from the existing 2s broker loop. client.report_stats(Mac::new(stats, blake3::hash(auth_token.as_bytes()).as_bytes())).await?; ``` -------------------------------- ### Geph5 Stats Data Flow Diagram Source: https://github.com/geph-official/geph5/blob/master/STATS.md Illustrates the flow of statistics from bridges and exits through the broker to Telegraf and Postgres, and how Grafana queries the data. ```text bridges ──(report_stats RPC, bridge_token MAC, 10s batches)──┐ exits ────(report_stats RPC, exit auth_token MAC, ~2s loop)──┤ broker's own metrics (RPC timers, self-stat gauges) ─────────┴─► broker broker ──DogStatsD UDP, localhost:8125──► Telegraf ──batched SQL──► Postgres │ Grafana ◄── metric() / rollups ─┘ ``` -------------------------------- ### RSA FDH Blind Signature Signing and Unblinding Source: https://github.com/geph-official/geph5/blob/master/libraries/mizaru2/README.md Broker computes the blinded signature sigma' and returns it. Client recovers the unblinded signature sigma by multiplying with the inverse of the blinding factor r. ```plaintext sigma' = (T')^d_i mod N_i sigma = sigma' * r^-1 mod N_i ``` -------------------------------- ### Add a New Metric Counter Source: https://github.com/geph-official/geph5/blob/master/STATS.md Call this function to add a new counter metric. Telegraf will automatically create the corresponding table in PostgreSQL on the first flush. ```rust stats.counter("my_new_thing", &[("color", "red")], 1.0) ``` -------------------------------- ### metric() function Source: https://github.com/geph-official/geph5/blob/master/STATS.md The `metric()` function retrieves time-series metric data, supporting various aggregation methods and field selections. It unions data across different bucket granularities (hourly, minutely, raw) based on the bucket size and coverage. ```APIDOC ## metric(name text, from timestamptz, to timestamptz, bucket interval, agg text DEFAULT 'avg', field text DEFAULT 'value') **Returns:** TABLE ("time" timestamptz, tags jsonb, value double precision) **Description:** Retrieves metric data, automatically handling different aggregation levels (hourly, minutely, raw) based on the specified bucket interval and data availability. Useful for general metric retrieval. **Parameters:** - **name** (text): The name of the metric to query. - **from** (timestamptz): The start timestamp for the query. - **to** (timestamptz): The end timestamp for the query. - **bucket interval** (interval): The desired bucket size for aggregation. - **agg** (text, optional, default 'avg'): The aggregation method to use (e.g., 'avg', 'sum', 'max', 'min'). - **field** (text, optional, default 'value'): The specific field to retrieve from the metric data (e.g., 'mean', 'count' for timer tables). ### Example Usage (Postgres datasource for Grafana): ```sql -- per-exit throughput (kbps is kilobytes/s, ×8000 = bits/s) SELECT "time", tags->>'exit' AS exit, value * 8000 AS bps FROM metric('kbps', $__timeFrom(), $__timeTo(), interval '$__interval') ORDER BY 1; ``` ``` -------------------------------- ### Emit Stats from Bridges Source: https://github.com/geph-official/geph5/blob/master/STATS.md Bridges accumulate stats into a global batcher, which is drained to the broker every 10 seconds. Use this for accumulating counters with specific tags. ```rust // bridges: accumulate into the global batcher (see geph5-bridge/src/stats.rs); // a background loop drains it to the broker every 10s. STAT_BATCHER.counter("bridge_bytes", &[("pool", pool), ("asn", asn), ("country", cc)], bytes); ``` -------------------------------- ### RSA FDH Blind Signature Verification Source: https://github.com/geph-official/geph5/blob/master/libraries/mizaru2/README.md Exit node verifies the signature by checking the Merkle proof for the public key, the signature against the token hash, and ensuring the key's epoch matches the current 24-hour window. ```plaintext sigma^e_i mod N_i == H(T) ``` -------------------------------- ### RSA FDH Blind Signature Token Blinding Source: https://github.com/geph-official/geph5/blob/master/libraries/mizaru2/README.md Client-side computation of a blinded token T' using a random blinding factor r and the current day's public RSA key (N_i, e_i). H is an FDH based on SHA-256. ```plaintext T' = (H(T) * r^e_i) mod N_i ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.