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(())
|
||||
}
|
||||
|
||||
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<_>>();
|
||||
if addrs.is_empty() {
|
||||
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")]
|
||||
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) {
|
||||
tracing::warn!("DIRECT: Failed to bind to physical interface {}: {}", idx, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub mod socks;
|
|||
pub struct OutboundManager {
|
||||
balancer: Arc<Balancer>,
|
||||
phys_if_index: Option<u32>,
|
||||
phys_if_name: Option<String>,
|
||||
_phys_if_name: Option<String>,
|
||||
}
|
||||
|
||||
impl OutboundManager {
|
||||
|
|
@ -23,7 +23,7 @@ impl OutboundManager {
|
|||
Self {
|
||||
balancer,
|
||||
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::io::{BufRead, BufReader};
|
||||
|
||||
let mut target_inode = None;
|
||||
let hex_port = format!("{:04X}", port);
|
||||
|
||||
let check_net_file = |path: &str| -> Option<u64> {
|
||||
|
|
@ -146,12 +145,11 @@ pub fn get_process_name_from_port(port: u16) -> Option<String> {
|
|||
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/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);
|
||||
|
||||
for entry in fs::read_dir("/proc").ok()?.filter_map(Result::ok) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||
use std::io::{Cursor, Read, Write};
|
||||
use std::io::{Cursor, Read};
|
||||
|
||||
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
|
||||
# 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.
|
||||
version: 0.3.10+23
|
||||
version: 0.3.11+24
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.4
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ostp-gui",
|
||||
"version": "0.3.10",
|
||||
"version": "0.3.11",
|
||||
"identifier": "com.ospab.ostp",
|
||||
"build": {
|
||||
"frontendDist": "../src"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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)]
|
||||
#[serde(tag = "protocol", rename_all = "snake_case")]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::net::SocketAddr;
|
|||
use bytes::Bytes;
|
||||
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::UiEvent;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ pub async fn create(opts: OstpTunOptions) -> Result<OstpTunInterface> {
|
|||
.mtu(opts.mtu)
|
||||
.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::AsyncDevice::new(dev).map_err(|e| anyhow!("TUN device async failed: {}", e))?;
|
||||
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
|
||||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ impl UserConfig {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct OutboundConfig {
|
||||
enabled: bool,
|
||||
|
|
@ -297,6 +298,7 @@ struct OutboundConfig {
|
|||
default_action: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct OutboundRule {
|
||||
domain_suffix: Option<Vec<String>>,
|
||||
|
|
@ -305,6 +307,7 @@ struct OutboundRule {
|
|||
action: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
struct TransportConfigRaw {
|
||||
mode: Option<String>,
|
||||
|
|
@ -360,6 +363,7 @@ impl ListenConfig {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct ApiConfig {
|
||||
enabled: Option<bool>,
|
||||
|
|
@ -370,6 +374,7 @@ struct ApiConfig {
|
|||
password_hash: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct FallbackCfg {
|
||||
enabled: Option<bool>,
|
||||
|
|
@ -922,7 +927,7 @@ fn run_setup_wizard(config_path: &std::path::Path) -> Result<()> {
|
|||
};
|
||||
|
||||
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!({
|
||||
"mode": "server",
|
||||
"version": "{}",
|
||||
|
|
@ -1324,7 +1329,7 @@ async fn run_app() -> Result<()> {
|
|||
AppMode::Server(s) => {
|
||||
println!("{} Config OK: server mode", "[ostp]".green().bold());
|
||||
let mut keys_count = 0;
|
||||
let mut has_outbound = false;
|
||||
let mut _has_outbound = false;
|
||||
for inbound in &s.inbounds {
|
||||
match inbound {
|
||||
ostp_server::config::ServerInbound::Ostp { listen, port, users, fallback, .. } => {
|
||||
|
|
@ -1348,7 +1353,7 @@ async fn run_app() -> Result<()> {
|
|||
for ob in &s.outbounds {
|
||||
if let ostp_server::config::ServerOutbound::Socks { server, port, .. } = ob {
|
||||
println!(" Outbound Proxy: SOCKS5 {}:{}", server.cyan(), port.to_string().cyan());
|
||||
has_outbound = true;
|
||||
_has_outbound = true;
|
||||
}
|
||||
}
|
||||
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 ob.get("enabled").and_then(|e| e.as_bool()).unwrap_or(false) {
|
||||
let tag = "socks5-legacy";
|
||||
let mut socks = serde_json::json!({
|
||||
let socks = serde_json::json!({
|
||||
"protocol": "socks5",
|
||||
"tag": tag,
|
||||
"server": ob.get("address").and_then(|a| a.as_str()).unwrap_or("127.0.0.1"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue