MCPcopy Create free account
hub / github.com/Recordscript/recordscript / increase_port

Function increase_port

libs/hbb_common/src/socket_client.rs:28–50  ·  view source on GitHub ↗
(host: T, offset: i32)

Source from the content-addressed store, hash-verified

26
27#[inline]
28pub fn increase_port<T: std::string::ToString>(host: T, offset: i32) -> String {
29 let host = host.to_string();
30 if crate::is_ipv6_str(&host) {
31 if host.starts_with('[') {
32 let tmp: Vec<&str> = host.split("]:").collect();
33 if tmp.len() == 2 {
34 let port: i32 = tmp[1].parse().unwrap_or(0);
35 if port > 0 {
36 return format!("{}]:{}", tmp[0], port + offset);
37 }
38 }
39 }
40 } else if host.contains(':') {
41 let tmp: Vec<&str> = host.split(':').collect();
42 if tmp.len() == 2 {
43 let port: i32 = tmp[1].parse().unwrap_or(0);
44 if port > 0 {
45 return format!("{}:{}", tmp[0], port + offset);
46 }
47 }
48 }
49 host
50}
51
52pub fn test_if_valid_server(host: &str, test_with_proxy: bool) -> String {
53 let host = check_port(host, 0);

Callers

nothing calls this directly

Calls 3

is_ipv6_strFunction · 0.85
to_stringMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected