file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
.vitepress/config.mts
TypeScript
import { defineConfig } from 'vitepress' const fileAndStyles: Record<string, string> = {} // https://vitepress.dev/reference/site-config export default defineConfig({ title: 'naive-ui-vitepress-demo', description: 'naive-ui vitepress demo', themeConfig: { // https://vitepress.dev/reference/default-theme-con...
07akioni/naive-ui-vitepress-demo
8
This is a demo for using `naive-ui` in `vitepress` with SSR enabled.
TypeScript
07akioni
07akioni
DeepSeek
.vitepress/theme/index.js
JavaScript
// .vitepress/theme/index.js import { defineComponent, h, inject } from 'vue' import DefaultTheme from 'vitepress/theme' import { NConfigProvider } from 'naive-ui' import { setup } from '@css-render/vue3-ssr' import { useRoute } from 'vitepress' const { Layout } = DefaultTheme const CssRenderStyle = defineComponent(...
07akioni/naive-ui-vitepress-demo
8
This is a demo for using `naive-ui` in `vitepress` with SSR enabled.
TypeScript
07akioni
07akioni
DeepSeek
eslint.config.mjs
JavaScript
// @ts-check import { createConfigForNuxt } from '@nuxt/eslint-config/flat' // Run `npx @eslint/config-inspector` to inspect the resolved config interactively export default createConfigForNuxt({ features: { // Rules for module authors tooling: true, // Rules for formatting stylistic: true, }, di...
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
playground/app.vue
Vue
<template> <NConfigProvider inline-theme-disabled> <NButton>Hello World</NButton> </NConfigProvider> </template> <script setup lang="ts"> import { NButton, NConfigProvider } from 'naive-ui' </script>
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
playground/nuxt.config.ts
TypeScript
export default defineNuxtConfig({ modules: ['../src/module'], devtools: { enabled: true }, })
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
src/module.ts
TypeScript
import { defineNuxtModule, createResolver, addPlugin } from '@nuxt/kit' // Module options TypeScript interface definition export interface ModuleOptions {} export default defineNuxtModule<ModuleOptions>({ meta: { name: 'nuxtjs-naive-ui', configKey: 'naive-ui', }, // Default configuration options of the ...
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
src/runtime/plugin.ts
TypeScript
import { setup } from '@css-render/vue3-ssr' import { defineNuxtPlugin } from '#app' export default defineNuxtPlugin((_nuxtApp) => { if (import.meta.server) { const { collect } = setup(_nuxtApp.vueApp) _nuxtApp.hooks.hook('app:rendered', () => { if (_nuxtApp.ssrContext) { if (typeof _nuxtApp.ss...
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
test/basic.test.ts
TypeScript
import { fileURLToPath } from 'node:url' import { describe, it, expect } from 'vitest' import { setup, $fetch } from '@nuxt/test-utils/e2e' describe('ssr', async () => { await setup({ rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)), }) it('renders the index page', async () => { // G...
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
test/fixtures/basic/app.vue
Vue
<template> <div>basic</div> </template> <script setup> </script>
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
test/fixtures/basic/nuxt.config.ts
TypeScript
import MyModule from '../../../src/module' export default defineNuxtConfig({ modules: [ MyModule, ], })
07akioni/nuxtjs-naive-ui
27
The official nuxt module for naive-ui that supports Nuxt.js SSR.
TypeScript
07akioni
07akioni
DeepSeek
config.mjs
JavaScript
import path from "path"; import { fileURLToPath } from "url"; import HtmlWebpackPlugin from "html-webpack-plugin"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const isRunningWebpack = !!process.env.WEBPACK; const isRunningRspack = !!process.env.RSPACK; if (!isRunningRspack && !isRunningWebpack) { ...
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
rspack-dist/index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Webpack App</title> <meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="main.js"></script></head> <body> </body> </html>
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
rspack-dist/main.js
JavaScript
(function() { var __webpack_modules__ = { "./src/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */var micromark_extension_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! micromark-extensio...
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
src/index.js
JavaScript
import { math } from "micromark-extension-math"; console.log(math); import("katex").then((katex) => { console.log(katex); });
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
src/render.css
CSS
.text { color: blue; }
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
src/render.js
JavaScript
import './render.css' export function render() { const el = document.createElement('div') el.classList.add('text') document.getElementsByTagName('body')[0].appendChild(el) el.innerHTML = 'hello, world' }
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
webpack-dist/index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Webpack App</title> <meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="main.js"></script></head> <body> </body> </html>
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
webpack-dist/main.js
JavaScript
/******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ "./node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs": /*!****************************************************************************!*\ !*** ./node_modules/.pnpm/dequal@2.0.3/node_modules/deq...
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
webpack-dist/vendors-node_modules_pnpm_katex_0_16_9_node_modules_katex_dist_katex_mjs.js
JavaScript
"use strict"; (self["webpackChunkrspack_repro"] = self["webpackChunkrspack_repro"] || []).push([["vendors-node_modules_pnpm_katex_0_16_9_node_modules_katex_dist_katex_mjs"],{ /***/ "./node_modules/.pnpm/katex@0.16.9/node_modules/katex/dist/katex.mjs": /*!****************************************************************...
07akioni/rspack-treeshaking-issue-reprod
0
JavaScript
07akioni
07akioni
DeepSeek
mkdocs_argparse/__init__.py
Python
import importlib import re from typing import Callable, Iterable, Iterator from markdown.extensions import Extension from markdown.preprocessors import Preprocessor import argparse import json import mistune __all__ = ["MKArgparseExtension", "MkDocsArgparseException", "makeExtension"] def makeExtension() -> Extensio...
0x2b3bfa0/mkdocs-argparse
4
An MkDocs extension to generate documentation for argparse command-line applications
Python
0x2b3bfa0
Helio Machado
iterative
examples/boringssl_server.rs
Rust
//! Run with `cargo run --all-features --example boringssl_server` command. //! //! To connect through browser, navigate to "https://localhost:3000" url. use axum::{routing::get, Router}; use axum_server2::{self as axum_server2, tls_boringssl::BoringSSLConfig}; use std::net::SocketAddr; #[tokio::main] async fn main()...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/configure_addr_incoming.rs
Rust
//! Run with `cargo run --example configure_http` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use axum::{routing::get, Router}; use axum_server2::AddrIncomingConfig; use std::net::SocketAddr; use std::time::Duration; #[tokio::main] async fn main() { let app = Router::new(...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/configure_http.rs
Rust
//! Run with `cargo run --example configure_http` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use axum::{routing::get, Router}; use axum_server2::HttpConfig; use std::net::SocketAddr; #[tokio::main] async fn main() { let app = Router::new().route("/", get(|| async { "Hell...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/from_std_listener.rs
Rust
//! Run with `cargo run --example from_std_listener` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use axum::{routing::get, Router}; use std::net::{SocketAddr, TcpListener}; #[tokio::main] async fn main() { let app = Router::new().route("/", get(|| async { "Hello, world!" }...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/from_std_listener_rustls.rs
Rust
//! Run with `cargo run --all-features --example from_std_listener_rustls` //! command. //! //! To connect through browser, navigate to "https://localhost:3000" url. use axum::{routing::get, Router}; use axum_server2::tls_rustls::RustlsConfig; use std::net::{SocketAddr, TcpListener}; #[tokio::main] async fn main() { ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/graceful_shutdown.rs
Rust
//! Run with `cargo run --example graceful_shutdown` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. //! //! After 10 seconds: //! - If there aren't any connections alive, server will shutdown. //! - If there are connections alive, server will wait until deadline is elapsed. //! ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/hello_world.rs
Rust
//! Run with `cargo run --example hello_world` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use axum::{routing::get, Router}; use std::net::SocketAddr; #[tokio::main] async fn main() { let app = Router::new().route("/", get(|| async { "Hello, world!" })); let addr = S...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/http_and_https.rs
Rust
//! Run with `cargo run --all-features --example http_and_https` command. //! //! To connect through browser, navigate to "http://localhost:3000" url which should redirect to //! "https://localhost:3443". use axum::{http::uri::Uri, response::Redirect, routing::get, Router}; use axum_server2::tls_rustls::RustlsConfig; ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/remote_address.rs
Rust
//! Run with `cargo run --example remote_address` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use axum::{extract::ConnectInfo, routing::get, Router}; use std::net::SocketAddr; #[tokio::main] async fn main() { let app = Router::new() .route("/", get(handler)) ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/remote_address_using_tower.rs
Rust
//! Run with `cargo run --example remote_address_using_tower` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. use hyper::{server::conn::AddrStream, Body, Request, Response}; use std::{convert::Infallible, net::SocketAddr}; use tower::service_fn; use tower_http::add_extension::AddE...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/rustls_reload.rs
Rust
//! Run with `cargo run --all-features --example rustls_reload` command. //! //! To connect through browser, navigate to "https://localhost:3000" url. //! //! Certificate common name will be "localhost". //! //! After 20 seconds, certificate common name will be "reloaded". use axum::{routing::get, Router}; use axum_se...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/rustls_server.rs
Rust
//! Run with `cargo run --all-features --example rustls_server` command. //! //! To connect through browser, navigate to "https://localhost:3000" url. use axum::{routing::get, Router}; use axum_server2::tls_rustls::RustlsConfig; use std::net::SocketAddr; #[tokio::main] async fn main() { let app = Router::new().ro...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/rustls_session.rs
Rust
//! Run with `cargo run --all-features --example rustls_session` command. //! //! To connect through browser, navigate to "https://localhost:3000" url. use axum::{middleware::AddExtension, routing::get, Extension, Router}; use axum_server2::{ accept::Accept, tls_rustls::{RustlsAcceptor, RustlsConfig}, }; use ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
examples/shutdown.rs
Rust
//! Run with `cargo run --example shutdown` command. //! //! To connect through browser, navigate to "http://localhost:3000" url. //! //! Server will shutdown in 20 seconds. use axum::{routing::get, Router}; use axum_server2::Handle; use std::{net::SocketAddr, time::Duration}; use tokio::time::sleep; #[tokio::main] a...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/accept.rs
Rust
//! [`Accept`] trait and utilities. use std::{ future::{Future, Ready}, io, }; /// An asynchronous function to modify io stream and service. pub trait Accept<I, S> { /// IO stream produced by accept. type Stream; /// Service produced by accept. type Service; /// Future return value. ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/addr_incoming_config.rs
Rust
use std::time::Duration; /// A configuration for [`AddrIncoming`](hyper::server::conn::AddrIncoming). #[derive(Debug, Clone)] pub struct AddrIncomingConfig { pub(crate) tcp_sleep_on_accept_errors: bool, pub(crate) tcp_keepalive: Option<Duration>, pub(crate) tcp_keepalive_interval: Option<Duration>, pub...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/handle.rs
Rust
use crate::notify_once::NotifyOnce; use std::{ net::SocketAddr, sync::{ atomic::{AtomicUsize, Ordering}, Arc, Mutex, }, time::Duration, }; use tokio::{sync::Notify, time::sleep}; /// A handle for [`Server`](crate::server::Server). #[derive(Clone, Debug, Default)] pub struct Handle { ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/http_config.rs
Rust
use hyper::server::conn::Http; use std::time::Duration; /// A configuration for [`Http`]. #[derive(Debug, Clone)] pub struct HttpConfig { pub(crate) inner: Http, } impl Default for HttpConfig { fn default() -> Self { Self::new() } } impl HttpConfig { /// Creates a default [`Http`] config. ...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/lib.rs
Rust
//! axum-server2 is a [hyper] server implementation designed to be used with [axum] framework. //! //! # Features //! //! - HTTP/1 and HTTP/2 //! - HTTPS through [rustls] or [openssl]. //! - High performance through [hyper]. //! - Using [tower] make service API. //! - Very good [axum] compatibility. Likely to work with...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/notify_once.rs
Rust
use std::sync::atomic::{AtomicBool, Ordering}; use tokio::sync::Notify; #[derive(Debug, Default)] pub(crate) struct NotifyOnce { notified: AtomicBool, notify: Notify, } impl NotifyOnce { pub(crate) fn notify_waiters(&self) { self.notified.store(true, Ordering::SeqCst); self.notify.notify_...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/server.rs
Rust
use crate::{ accept::{Accept, DefaultAcceptor}, addr_incoming_config::AddrIncomingConfig, handle::Handle, http_config::HttpConfig, service::{MakeServiceRef, SendService}, }; use futures_util::future::poll_fn; use http::Request; use hyper::server::{ accept::Accept as HyperAccept, conn::{AddrI...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/service.rs
Rust
//! Service traits. use http::Response; use http_body::Body; use std::{ future::Future, task::{Context, Poll}, }; use tower_service::Service; /// Trait alias for [`Service`] with bounds required for [`serve`](crate::server::Server::serve). /// /// This trait is sealed and cannot be implemented for types outsi...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_boringssl/future.rs
Rust
//! Future types. use super::BoringSSLConfig; use futures_util::future::BoxFuture; use pin_project_lite::pin_project; use std::io::{Error, ErrorKind}; use std::time::Duration; use std::{ fmt, future::Future, io, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_boringssl/mod.rs
Rust
//! Tls implementation using [`openssl`] //! //! # Example //! //! ```rust,no_run //! use axum::{routing::get, Router}; //! use axum_server2::tls_boringssl::BoringSSLConfig; //! use std::net::SocketAddr; //! //! #[tokio::main] //! async fn main() { //! let app = Router::new().route("/", get(|| async { "Hello, world...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_openssl/future.rs
Rust
//! Future types. use super::OpenSSLConfig; use pin_project_lite::pin_project; use std::io::{Error, ErrorKind}; use std::time::Duration; use std::{ fmt, future::Future, io, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::{timeout, Timeout}; use openssl:...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_openssl/mod.rs
Rust
//! Tls implementation using [`openssl`] //! //! # Example //! //! ```rust,no_run //! use axum::{routing::get, Router}; //! use axum_server2::tls_openssl::OpenSSLConfig; //! use std::net::SocketAddr; //! //! #[tokio::main] //! async fn main() { //! let app = Router::new().route("/", get(|| async { "Hello, world!" }...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_rustls/future.rs
Rust
//! Future types. use crate::tls_rustls::RustlsConfig; use pin_project_lite::pin_project; use std::io::{Error, ErrorKind}; use std::time::Duration; use std::{ fmt, future::Future, io, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::time::{timeout, Timeout}; us...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/tls_rustls/mod.rs
Rust
//! Tls implementation using [`rustls`]. //! //! # Example //! //! ```rust,no_run //! use axum::{routing::get, Router}; //! use axum_server2::tls_rustls::RustlsConfig; //! use std::net::SocketAddr; //! //! #[tokio::main] //! async fn main() { //! let app = Router::new().route("/", get(|| async { "Hello, world!" }))...
0x676e67/axum-server2
3
High level server designed to be used with axum framework.
Rust
0x676e67
src/config.rs
Rust
use crate::{error::Error, proxy::Proxies}; use serde::{Deserialize, Serialize}; use std::{ net::{IpAddr, Ipv4Addr, SocketAddr}, path::PathBuf, }; #[derive(Serialize, Deserialize, Clone)] pub struct Config { /// Debug model pub debug: bool, /// Server bind address pub bind: SocketAddr, ///...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/daemon.rs
Rust
use crate::serve; use daemonize::Daemonize; use std::{ fs::{File, Permissions}, os::unix::fs::PermissionsExt, path::{Path, PathBuf}, }; const PID_PATH: &str = "/var/run/duckai.pid"; const DEFAULT_STDOUT_PATH: &str = "/var/run/duckai.out"; const DEFAULT_STDERR_PATH: &str = "/var/run/duckai.err"; /// Get th...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/error.rs
Rust
#[derive(thiserror::Error, Debug)] pub enum Error { #[error(transparent)] IOError(#[from] std::io::Error), #[error(transparent)] ParseIntError(#[from] std::num::ParseIntError), #[error(transparent)] NetworkParseError(#[from] cidr::errors::NetworkParseError), #[error(transparent)] Addr...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/main.rs
Rust
mod config; #[cfg(target_family = "unix")] mod daemon; mod error; mod proxy; mod serve; use clap::{Args, Parser, Subcommand}; pub use error::Error; use std::path::PathBuf; #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; ty...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/proxy.rs
Rust
use cidr::IpCidr; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::net::IpAddr; use url::Url; #[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Proxies { /// Upstream proxy, supports http, https, socks4, socks5, socks5h URL(Url), /// Bind to interface, s...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/build.rs
Rust
use super::dns; use hickory_resolver::config::LookupIpStrategy; use rand::seq::SliceRandom; use rquest::{tls::Impersonate, Client, ClientBuilder, Proxy}; use std::{net::IpAddr, time::Duration}; use typed_builder::TypedBuilder; use url::Url; #[derive(TypedBuilder, Clone)] pub struct HttpConfig { /// Timeout for eac...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/dns/fast.rs
Rust
use std::time::Instant; use futures_util::future::join_all; use hickory_resolver::{ config::{LookupIpStrategy, ResolverConfig, ResolverOpts}, TokioAsyncResolver, }; use tokio::sync::OnceCell; pub const FASTEST_DNS_CONFIG: OnceCell<ResolverConfig> = OnceCell::const_new(); /// Fastest DNS resolver pub async fn...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/dns/mod.rs
Rust
//! DNS resolution via the [trust_dns_resolver](https://github.com/bluejekyll/trust-dns) crate mod fast; use std::{ io, net::SocketAddr, sync::{Arc, OnceLock}, }; pub use hickory_resolver::config::{ResolverConfig, ResolverOpts}; use hickory_resolver::{ config::{LookupIpStrategy, NameServerConfigGroup}...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/mod.rs
Rust
mod build; mod dns; mod pool; #[cfg(target_os = "linux")] mod route; use crate::config; use pool::Pool; use std::{ops::Deref, sync::Arc}; /// Client round-robin balancer #[derive(Clone)] pub struct ClientLoadBalancer { pool: Arc<Pool>, _priv: (), } impl ClientLoadBalancer { pub async fn new(conf: config:...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/pool.rs
Rust
use super::build::{self, HttpConfig}; use crate::{config::Config, proxy::Proxies}; use cidr::IpCidr; use rand::Rng; use rquest::Client; use std::{ net::IpAddr, sync::atomic::{AtomicUsize, Ordering}, }; pub enum Pool { Default(Client), Ifaces { load_factor: AtomicUsize, clients: Vec<Clie...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/client/route.rs
Rust
use futures_util::TryStreamExt; use netlink_packet_route::{ route::{RouteAddress, RouteAttribute, RouteProtocol, RouteScope, RouteType}, AddressFamily, }; use rtnetlink::{new_connection, Error, Handle, IpVersion}; /// Attempts to add a route to the given subnet on the loopback interface. /// /// This function ...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/mod.rs
Rust
mod client; mod model; mod route; mod signal; use crate::Result; use crate::{config::Config, error::Error}; use axum::Json; use axum::{ extract::DefaultBodyLimit, http::StatusCode, response::IntoResponse, routing::{get, post}, Router, }; use axum_extra::headers::authorization::Bearer; use axum_extr...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/model.rs
Rust
use serde::{Deserialize, Deserializer, Serialize}; use typed_builder::TypedBuilder; /// A role of a message sender, can be: /// - `System`, for starting system message, that sets the tone of model /// - `Assistant`, for messages sent by ChatGPT /// - `User`, for messages sent by user #[derive(Debug, Serialize, Deseria...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/route.rs
Rust
use super::{ model::{ChatRequest, ModelData, Models, Pong}, AppState, }; use crate::error::Error; use crate::Result; use axum::{extract::State, response::Response, Json}; use axum_extra::{ extract::WithRejection, headers::{authorization::Bearer, Authorization}, TypedHeader, }; use process::ChatProce...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
src/serve/signal.rs
Rust
use std::time::Duration; use axum_server::Handle; #[cfg(target_family = "unix")] use tokio::signal::unix::{signal, SignalKind}; use tokio::time::sleep; use tracing::info; pub(super) async fn graceful_shutdown(handle: Handle) { #[cfg(target_family = "windows")] { tokio::signal::ctrl_c() .aw...
0x676e67/duckai
40
DuckDuckGo AI to OpenAI API
Rust
0x676e67
benches/hashmemo.rs
Rust
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use hashmemo::HashMemo; use std::{ collections::HashMap, fmt::{Display, Formatter}, hash::{BuildHasher, Hash, RandomState}, }; use ahash::RandomState as AHashBuilder; #[derive(Clone, Eq, PartialEq, Hash)] struct BigStruct { name...
0x676e67/hashmemo
0
Hash value memoization
Rust
0x676e67
src/lib.rs
Rust
//! # HashMemo - Hash Value Memoization //! //! A library for memoizing hash values of complex data structures to improve performance //! when the same data is hashed multiple times. //! //! This library is particularly beneficial for **large data structures** where computing //! hash values is expensive (e.g., large s...
0x676e67/hashmemo
0
Hash value memoization
Rust
0x676e67
.github/build.sh
Shell
#!/bin/bash : ${root=$(pwd)} : ${tag=latest} : ${os=linux} : ${name=pingly} # Function to print colored text based on log level log() { local level=$1 local message=$2 local NC='\033[0m' # Reset to default color case "$level" in "info") echo -e "\033[0;32m[INFO] $message${NC}" # Green for INFO ;; ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/alloc.rs
Rust
//! Memory allocator #[cfg(feature = "jemalloc")] #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; #[cfg(feature = "tcmalloc")] #[global_allocator] static ALLOC: tcmalloc::TCMalloc = tcmalloc::TCMalloc; #[cfg(feature = "mimalloc")] #[global_allocator] static ALLOC: mimalloc::MiMallo...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/daemon.rs
Rust
use std::{ fs::{File, Permissions}, os::unix::fs::PermissionsExt, path::{Path, PathBuf}, }; use daemonize::Daemonize; use crate::{server, Args}; const DEFAULT_PID_PATH: &str = "/var/run/pingly.pid"; const DEFAULT_STDOUT_PATH: &str = "/var/run/pingly.out"; const DEFAULT_STDERR_PATH: &str = "/var/run/pingl...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/error.rs
Rust
pub type Result<T, E = Error> = std::result::Result<T, E>; #[derive(thiserror::Error, Debug)] pub enum Error { #[error(transparent)] IO(#[from] std::io::Error), #[error(transparent)] ParseInt(#[from] std::num::ParseIntError), #[error(transparent)] AddressParse(#[from] std::net::AddrParseError...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/main.rs
Rust
#![cfg_attr(not(test), warn(unused_crate_dependencies))] mod alloc; #[cfg(target_family = "unix")] mod daemon; mod error; mod server; use std::{net::SocketAddr, path::PathBuf}; use clap::{Parser, Subcommand}; use error::Result; #[derive(Parser)] #[clap(author, version, about, arg_required_else_help = true)] #[comma...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/certificate.rs
Rust
use std::{io, path::Path, sync::Arc}; use axum_server::tls_rustls::RustlsConfig; use rcgen::{ date_time_ymd, BasicConstraints, CertificateParams, DistinguishedName, DnType, IsCa, KeyPair, KeyUsagePurpose, SanType, }; use rustls_pemfile::Item; use tokio_rustls::rustls::{ pki_types::{CertificateDer, PrivateK...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/mod.rs
Rust
mod certificate; mod signal; mod tracker; use std::{net::SocketAddr, str::FromStr, time::Duration}; use axum::{ body::Body, extract::ConnectInfo, http::{Request, StatusCode}, response::IntoResponse, routing::any, Extension, Router, }; use axum_extra::response::ErasedJson; use axum_server::Hand...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/signal.rs
Rust
use std::time::Duration; use axum_server::Handle; use tokio::time::sleep; use tracing::info; #[cfg(target_os = "linux")] use super::tracker::capture::TcpCaptureTrack; pub(super) async fn graceful_shutdown( handle: Handle, #[cfg(target_os = "linux")] capture: Option<TcpCaptureTrack>, ) { tokio::signal::ct...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/accept.rs
Rust
use std::io; use axum::{middleware::AddExtension, Extension}; use axum_server::{accept::Accept, tls_rustls::RustlsAcceptor}; use futures_util::future::BoxFuture; use tokio::io::{AsyncRead, AsyncWrite}; use tower::Layer; use super::{ info::ConnectionTrack, inspector::{Http1Inspector, Http2Inspector, Inspector,...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/capture/mod.rs
Rust
mod parser; use std::{ collections::VecDeque, sync::{ atomic::{AtomicBool, Ordering}, Arc, Mutex, }, time::{SystemTime, UNIX_EPOCH}, }; use pcap::{Capture, Device}; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; #[derive(Debug, Clone, Serialize, Deserialize)]...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/capture/parser.rs
Rust
use std::time::{SystemTime, UNIX_EPOCH}; use serde_json::Value as JsonValue; use super::CapturedPacket; pub fn parse_packet_with_pktparse(data: &[u8]) -> Option<JsonValue> { use pktparse::{ethernet, ip::IPProtocol, ipv4, ipv6, tcp}; use serde_json::{json, to_value}; // Try to parse the ethernet frame ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/info.rs
Rust
use std::net::SocketAddr; use axum::{ body::Body, http::{header::USER_AGENT, HeaderValue, Method, Request}, }; use serde::{Serialize, Serializer}; use tokio_rustls::rustls::ProtocolVersion; use super::inspector::{ClientHello, Frame, Http1Headers, Http2Frame, LazyClientHello}; #[cfg(target_os = "linux")] use ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http1.rs
Rust
use std::{ops::Deref, pin::Pin, sync::Arc, task, task::Poll}; use bytes::Bytes; use pin_project_lite::pin_project; use tokio::io::{self, AsyncRead, AsyncWrite, ReadBuf}; use tokio_rustls::server::TlsStream; use super::tls::TlsInspector; pub type Http1Headers = Arc<boxcar::Vec<(Bytes, Bytes)>>; pin_project! { //...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/error.rs
Rust
/// Errors that can occur during parsing an HTTP/2 frame. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Error { /// A length value other than 8 was set on a PING message. BadFrameSize, /// The padding length was larger than the frame-header-specified /// length of the payload. TooMuchPadding, ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/headers.rs
Rust
use std::fmt::Write; use httlib_hpack::Decoder; use serde::{Serialize, Serializer}; use super::{error::Error, priority::StreamDependency, FrameType}; /// Header frame #[derive(Debug, Serialize)] pub struct HeadersFrame { /// The type of the frame pub frame_type: FrameType, /// The ID of the stream with ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/mod.rs
Rust
mod error; mod headers; mod priority; mod settings; mod window_update; use headers::HeadersFrame; use priority::PriorityFrame; use serde::Serialize; use settings::SettingsFrame; use window_update::WindowUpdateFrame; pub fn parse(data: &[u8]) -> (usize, Option<Frame>) { const FRAME_HEADER_LEN: usize = 9; if d...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/priority.rs
Rust
use serde::Serialize; use super::{error::Error, FrameType}; /// The PRIORITY frame (type=0x2) specifies the sender-advised priority /// of a stream [Section 5.3]. It can be sent in any stream state, /// including idle or closed streams. /// [Section 5.3]: <https://tools.ietf.org/html/rfc7540#section-5.3> #[derive(De...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/settings.rs
Rust
use serde::Serialize; use super::{error::Error, FrameType}; /// An enum that lists all valid settings that can be sent in a SETTINGS /// frame. /// /// Each setting has a value that is a 32 bit unsigned integer (6.5.1.). #[derive(Debug, Serialize)] pub enum Setting { HeaderTableSize { id: u16, value: u32 }, E...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/frame/window_update.rs
Rust
use serde::Serialize; use super::{error::Error, FrameType}; /// Represents an HTTP/2 WINDOW_UPDATE frame. /// /// See RFC 7540, Section 6.9: <https://datatracker.ietf.org/doc/html/rfc7540#section-6.9> /// This frame is used for flow control, indicating how many additional bytes the sender is /// permitted to transmit...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/http2/mod.rs
Rust
pub mod frame; use std::{ops::Deref, pin::Pin, sync::Arc, task, task::Poll}; use frame::Frame; use pin_project_lite::pin_project; use tokio::io::{self, AsyncRead, AsyncWrite, ReadBuf}; use tokio_rustls::server::TlsStream; use super::tls::TlsInspector; pub type Http2Frame = Arc<boxcar::Vec<Frame>>; pin_project! { ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/mod.rs
Rust
mod http1; mod http2; mod tls; use std::{pin::Pin, task, task::Poll}; pub use http1::{Http1Headers, Http1Inspector}; pub use http2::{frame::Frame, Http2Frame, Http2Inspector}; pub use tls::{ClientHello, LazyClientHello, TlsInspector}; use tokio::io::{self, AsyncRead, AsyncWrite, ReadBuf}; /// `Inspector` is an enum ...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/tls/enums.rs
Rust
#![allow(non_camel_case_types)] enum_builder! { /// The `TlsVersion` TLS protocol enum. Values in this enum are taken /// from the various RFCs covering TLS, and are listed by IANA. /// The `Unknown` item is used when processing unrecognised ordinals. @U16 pub enum TlsVersion { SSLv2 => 0x...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/tls/hello.rs
Rust
//! See: <https://www.rfc-editor.org/rfc/rfc8446#section-4.2> use serde::Serialize; use tls_parser::{TlsCipherSuite, TlsExtensionType, TlsMessage, TlsMessageHandshake}; use tokio_rustls::rustls::ProtocolVersion; use super::{ enums::{ AuthenticatedEncryptionWithAssociatedData, CertificateCompressionAlgorit...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/tls/macros.rs
Rust
macro_rules! enum_builder { ( $(#[$m:meta])* @U8 $enum_vis:vis enum $enum_name:ident { $( $(#[$enum_meta:meta])* $enum_var: ident => $enum_val: expr ),* $(,)? } ) => { $(#[$m])* #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] $enum_vis enum $e...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/tls/mod.rs
Rust
#[macro_use] mod macros; mod enums; mod hello; mod parser; use std::{pin::Pin, task, task::Poll}; pub use hello::{ClientHello, LazyClientHello}; use tokio::io::{self, AsyncRead, AsyncWrite, ReadBuf}; pin_project_lite::pin_project! { /// A wrapper over a TLS stream that inspects TLS client hello messages. ///...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/inspector/tls/parser.rs
Rust
use nom::{ combinator::{map, map_opt, map_parser}, error::{make_error, ErrorKind}, multi::length_data, number::streaming::{be_u16, be_u8}, IResult, Parser, }; use super::hello::{ECHClientHello, ECHClientHelloOuter, HpkeSymmetricCipherSuite, TlsExtension}; /// Parse KeyShare extension in TLS 1.3 (R...
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
src/server/tracker/mod.rs
Rust
pub mod accept; #[cfg(target_os = "linux")] pub mod capture; pub mod info; mod inspector;
0x676e67/pingly
26
Analysis server for TLS and HTTP/1/2/3
Rust
0x676e67
examples/client.rs
Rust
//! This example demonstrates an HTTP client that requests files from a server. //! //! Checkout the `README.md` for guidance. use std::{ fs, io::{self, Write}, net::{SocketAddr, ToSocketAddrs}, path::PathBuf, sync::Arc, time::{Duration, Instant}, }; use anyhow::{anyhow, Result}; use boring::x...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
examples/server.rs
Rust
//! This example demonstrates an HTTP server that serves files from a directory. //! //! Checkout the `README.md` for guidance. use std::{ ascii, fs, io, net::SocketAddr, path::{self, Path, PathBuf}, str, sync::Arc, }; use anyhow::{anyhow, bail, Context, Result}; use boring::pkey::PKey; use boring...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/aead.rs
Rust
use crate::error::{map_result, Error, Result}; use crate::key::{Key, Nonce, Tag}; use boring_sys as bffi; use once_cell::sync::Lazy; use std::mem::MaybeUninit; const AES_128_GCM_KEY_LEN: usize = 16; const AES_256_GCM_KEY_LEN: usize = 32; const CHACHA20_POLY1305_KEY_LEN: usize = 32; const AES_GCM_NONCE_LEN: usize = 12...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/alert.rs
Rust
use boring_sys as bffi; use quinn_proto::{TransportError, TransportErrorCode}; use std::ffi::{c_int, CStr}; use std::fmt; use std::fmt::{Display, Formatter}; use std::str::FromStr; pub(crate) enum AlertType { Warning, Fatal, Unknown, } impl AlertType { const ALERT_TYPE_WARNING: &'static str = "warning...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/alpn.rs
Rust
use crate::error::{Error, Result}; #[derive(Clone, Debug)] pub(crate) struct AlpnProtocol(Vec<u8>); impl AlpnProtocol { #[inline] pub(crate) fn encode(&self, encoded: &mut Vec<u8>) { encoded.push(self.0.len() as u8); encoded.extend_from_slice(&self.0); } } impl From<Vec<u8>> for AlpnProto...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/bffi_ext.rs
Rust
use crate::error::{br, br_zero_is_success, BoringResult}; use boring::error::ErrorStack; use boring::pkey::{HasPrivate, PKey}; use boring::ssl::{Ssl, SslContext, SslContextRef, SslSession}; use boring::x509::store::X509StoreBuilderRef; use boring::x509::X509; use boring_sys as bffi; use bytes::{Buf, BufMut}; use foreig...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/client.rs
Rust
use crate::alpn::AlpnProtocols; use crate::bffi_ext::QuicSslContext; use crate::error::{map_result, Result}; use crate::session_state::{SessionState, QUIC_METHOD}; use crate::version::QuicVersion; use crate::{Entry, KeyLog, NoKeyLog, QuicSsl, QuicSslSession, SessionCache, SimpleCache}; use boring::ssl::{Ssl, SslContext...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/error.rs
Rust
use boring::error::ErrorStack; use quinn_proto::{crypto, ConnectError, TransportError}; use std::ffi::c_int; use std::fmt::{Debug, Display, Formatter}; use std::io::ErrorKind; use std::result::Result as StdResult; use std::{fmt, io}; // Error conversion: pub enum Error { SslError(ErrorStack), IoError(io::Error...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67