mirror of https://github.com/ospab/ostp.git
Fix compiler warnings and errors
This commit is contained in:
parent
72077bbd0c
commit
8a0b633bb1
|
|
@ -66,7 +66,7 @@ pub fn bind_socket_to_interface(socket: &tokio::net::TcpSocket, _is_ipv6: bool,
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn dial_tcp(target_host: &str, target_port: u16, phys_if_idx: Option<u32>) -> Result<TcpStream> {
|
pub async fn dial_tcp(target_host: &str, target_port: u16, _phys_if_idx: Option<u32>) -> Result<TcpStream> {
|
||||||
let addrs = tokio::net::lookup_host((target_host, target_port)).await?.collect::<Vec<_>>();
|
let addrs = tokio::net::lookup_host((target_host, target_port)).await?.collect::<Vec<_>>();
|
||||||
if addrs.is_empty() {
|
if addrs.is_empty() {
|
||||||
return Err(anyhow!("Could not resolve target host: {}", target_host));
|
return Err(anyhow!("Could not resolve target host: {}", target_host));
|
||||||
|
|
@ -79,7 +79,7 @@ pub async fn dial_tcp(target_host: &str, target_port: u16, phys_if_idx: Option<u
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
if let Some(idx) = phys_if_idx {
|
if let Some(idx) = _phys_if_idx {
|
||||||
if let Err(e) = bind_socket_to_interface(&socket, target_addr.is_ipv6(), idx) {
|
if let Err(e) = bind_socket_to_interface(&socket, target_addr.is_ipv6(), idx) {
|
||||||
tracing::warn!("DIRECT: Failed to bind to physical interface {}: {}", idx, e);
|
tracing::warn!("DIRECT: Failed to bind to physical interface {}: {}", idx, e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ pub mod socks;
|
||||||
pub struct OutboundManager {
|
pub struct OutboundManager {
|
||||||
balancer: Arc<Balancer>,
|
balancer: Arc<Balancer>,
|
||||||
phys_if_index: Option<u32>,
|
phys_if_index: Option<u32>,
|
||||||
phys_if_name: Option<String>,
|
_phys_if_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutboundManager {
|
impl OutboundManager {
|
||||||
|
|
@ -23,7 +23,7 @@ impl OutboundManager {
|
||||||
Self {
|
Self {
|
||||||
balancer,
|
balancer,
|
||||||
phys_if_index,
|
phys_if_index,
|
||||||
phys_if_name,
|
_phys_if_name: phys_if_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,6 @@ pub fn get_process_name_from_port(port: u16) -> Option<String> {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
|
|
||||||
let mut target_inode = None;
|
|
||||||
let hex_port = format!("{:04X}", port);
|
let hex_port = format!("{:04X}", port);
|
||||||
|
|
||||||
let check_net_file = |path: &str| -> Option<u64> {
|
let check_net_file = |path: &str| -> Option<u64> {
|
||||||
|
|
@ -146,12 +145,11 @@ pub fn get_process_name_from_port(port: u16) -> Option<String> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
target_inode = check_net_file("/proc/net/tcp")
|
let target_inode = check_net_file("/proc/net/tcp")
|
||||||
.or_else(|| check_net_file("/proc/net/tcp6"))
|
.or_else(|| check_net_file("/proc/net/tcp6"))
|
||||||
.or_else(|| check_net_file("/proc/net/udp"))
|
.or_else(|| check_net_file("/proc/net/udp"))
|
||||||
.or_else(|| check_net_file("/proc/net/udp6"));
|
.or_else(|| check_net_file("/proc/net/udp6"))?;
|
||||||
|
|
||||||
let target_inode = target_inode?;
|
|
||||||
let socket_str = format!("socket:[{}]", target_inode);
|
let socket_str = format!("socket:[{}]", target_inode);
|
||||||
|
|
||||||
for entry in fs::read_dir("/proc").ok()?.filter_map(Result::ok) {
|
for entry in fs::read_dir("/proc").ok()?.filter_map(Result::ok) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use std::io::{Cursor, Read, Write};
|
use std::io::{Cursor, Read};
|
||||||
|
|
||||||
const BASE32_ALPHABET: &[u8] = b"abcdefghijklmnopqrstuvwxyz234567";
|
const BASE32_ALPHABET: &[u8] = b"abcdefghijklmnopqrstuvwxyz234567";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.3.10+23
|
version: 0.3.11+24
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.11.4
|
sdk: ^3.11.4
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "ostp-gui",
|
"productName": "ostp-gui",
|
||||||
"version": "0.3.10",
|
"version": "0.3.11",
|
||||||
"identifier": "com.ospab.ostp",
|
"identifier": "com.ospab.ostp",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../src"
|
"frontendDist": "../src"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use crate::{api::ApiConfig, fallback::FallbackConfig, outbound::OutboundConfig, dns::DnsConfig};
|
use crate::{fallback::FallbackConfig, dns::DnsConfig};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
#[serde(tag = "protocol", rename_all = "snake_case")]
|
#[serde(tag = "protocol", rename_all = "snake_case")]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::net::SocketAddr;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use tokio::time::Duration;
|
use tokio::time::Duration;
|
||||||
|
|
||||||
use ostp_core::dns::{DnsPacket, DnsRecordType, decode_domain_to_payload, encode_payload_to_domain};
|
use ostp_core::dns::{DnsPacket, DnsRecordType, decode_domain_to_payload};
|
||||||
use crate::config::DnsTransportConfig;
|
use crate::config::DnsTransportConfig;
|
||||||
use crate::UiEvent;
|
use crate::UiEvent;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,6 @@ pub async fn create(opts: OstpTunOptions) -> Result<OstpTunInterface> {
|
||||||
.mtu(opts.mtu)
|
.mtu(opts.mtu)
|
||||||
.up();
|
.up();
|
||||||
|
|
||||||
tun_cfg.platform_config(|cfg| {
|
|
||||||
cfg.packet_information(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
let dev = tun::create(&tun_cfg).map_err(|e| anyhow!("Failed to create TUN device: {}", e))?;
|
let dev = tun::create(&tun_cfg).map_err(|e| anyhow!("Failed to create TUN device: {}", e))?;
|
||||||
let dev = tun::AsyncDevice::new(dev).map_err(|e| anyhow!("TUN device async failed: {}", e))?;
|
let dev = tun::AsyncDevice::new(dev).map_err(|e| anyhow!("TUN device async failed: {}", e))?;
|
||||||
tracing::info!("TUN device 'ostp_tun' created.");
|
tracing::info!("TUN device 'ostp_tun' created.");
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ pub async fn run_prober(config_path: &std::path::Path) {
|
||||||
|
|
||||||
// Send a real OSTP ping packet encoded as a domain
|
// Send a real OSTP ping packet encoded as a domain
|
||||||
let payload = b"PING";
|
let payload = b"PING";
|
||||||
let encoded_domain = ostp_core::dns::encode_payload_to_domain(payload, target_domain);
|
let encoded_domain = ostp_core::dns::encode_payload_to_domain(payload, &target_domain);
|
||||||
|
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,7 @@ impl UserConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct OutboundConfig {
|
struct OutboundConfig {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
|
@ -297,6 +298,7 @@ struct OutboundConfig {
|
||||||
default_action: Option<String>,
|
default_action: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct OutboundRule {
|
struct OutboundRule {
|
||||||
domain_suffix: Option<Vec<String>>,
|
domain_suffix: Option<Vec<String>>,
|
||||||
|
|
@ -305,6 +307,7 @@ struct OutboundRule {
|
||||||
action: Option<String>,
|
action: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
struct TransportConfigRaw {
|
struct TransportConfigRaw {
|
||||||
mode: Option<String>,
|
mode: Option<String>,
|
||||||
|
|
@ -360,6 +363,7 @@ impl ListenConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct ApiConfig {
|
struct ApiConfig {
|
||||||
enabled: Option<bool>,
|
enabled: Option<bool>,
|
||||||
|
|
@ -370,6 +374,7 @@ struct ApiConfig {
|
||||||
password_hash: Option<String>,
|
password_hash: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
struct FallbackCfg {
|
struct FallbackCfg {
|
||||||
enabled: Option<bool>,
|
enabled: Option<bool>,
|
||||||
|
|
@ -922,7 +927,7 @@ fn run_setup_wizard(config_path: &std::path::Path) -> Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
wizard_step(4, TOTAL, "Saving configuration");
|
wizard_step(4, TOTAL, "Saving configuration");
|
||||||
let panel_bind = format!("0.0.0.0:{}", panel_port);
|
let _panel_bind = format!("0.0.0.0:{}", panel_port);
|
||||||
let server_json = serde_json::json!({
|
let server_json = serde_json::json!({
|
||||||
"mode": "server",
|
"mode": "server",
|
||||||
"version": "{}",
|
"version": "{}",
|
||||||
|
|
@ -1324,7 +1329,7 @@ async fn run_app() -> Result<()> {
|
||||||
AppMode::Server(s) => {
|
AppMode::Server(s) => {
|
||||||
println!("{} Config OK: server mode", "[ostp]".green().bold());
|
println!("{} Config OK: server mode", "[ostp]".green().bold());
|
||||||
let mut keys_count = 0;
|
let mut keys_count = 0;
|
||||||
let mut has_outbound = false;
|
let mut _has_outbound = false;
|
||||||
for inbound in &s.inbounds {
|
for inbound in &s.inbounds {
|
||||||
match inbound {
|
match inbound {
|
||||||
ostp_server::config::ServerInbound::Ostp { listen, port, users, fallback, .. } => {
|
ostp_server::config::ServerInbound::Ostp { listen, port, users, fallback, .. } => {
|
||||||
|
|
@ -1348,7 +1353,7 @@ async fn run_app() -> Result<()> {
|
||||||
for ob in &s.outbounds {
|
for ob in &s.outbounds {
|
||||||
if let ostp_server::config::ServerOutbound::Socks { server, port, .. } = ob {
|
if let ostp_server::config::ServerOutbound::Socks { server, port, .. } = ob {
|
||||||
println!(" Outbound Proxy: SOCKS5 {}:{}", server.cyan(), port.to_string().cyan());
|
println!(" Outbound Proxy: SOCKS5 {}:{}", server.cyan(), port.to_string().cyan());
|
||||||
has_outbound = true;
|
_has_outbound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(dns) = &s.dns {
|
if let Some(dns) = &s.dns {
|
||||||
|
|
@ -2021,7 +2026,7 @@ fn cmd_migrate(config_path: &std::path::Path) -> Result<()> {
|
||||||
if let Some(ob) = raw_json.get("outbound") {
|
if let Some(ob) = raw_json.get("outbound") {
|
||||||
if ob.get("enabled").and_then(|e| e.as_bool()).unwrap_or(false) {
|
if ob.get("enabled").and_then(|e| e.as_bool()).unwrap_or(false) {
|
||||||
let tag = "socks5-legacy";
|
let tag = "socks5-legacy";
|
||||||
let mut socks = serde_json::json!({
|
let socks = serde_json::json!({
|
||||||
"protocol": "socks5",
|
"protocol": "socks5",
|
||||||
"tag": tag,
|
"tag": tag,
|
||||||
"server": ob.get("address").and_then(|a| a.as_str()).unwrap_or("127.0.0.1"),
|
"server": ob.get("address").and_then(|a| a.as_str()).unwrap_or("127.0.0.1"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue