First working alpha, version a0.4. #6
@@ -60,6 +60,12 @@ namespace ColumnLynx::Net {
|
|||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t prefixLengthToNetmask(uint8_t prefixLen) {
|
||||||
|
if (prefixLen == 0) return 0;
|
||||||
|
uint32_t mask = (0xFFFFFFFF << (32 - prefixLen)) & 0xFFFFFFFF;
|
||||||
|
return htonl(mask); // convert to network byte order
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mApplyLinuxIP(uint32_t clientIP, uint32_t serverIP, uint8_t prefixLen, uint16_t mtu);
|
bool mApplyLinuxIP(uint32_t clientIP, uint32_t serverIP, uint8_t prefixLen, uint16_t mtu);
|
||||||
bool mApplyMacOSIP(uint32_t clientIP, uint32_t serverIP, uint8_t prefixLen, uint16_t mtu);
|
bool mApplyMacOSIP(uint32_t clientIP, uint32_t serverIP, uint8_t prefixLen, uint16_t mtu);
|
||||||
|
|||||||
@@ -192,6 +192,14 @@ namespace ColumnLynx::Net {
|
|||||||
ipStr.c_str(), peerStr.c_str(), mtu);
|
ipStr.c_str(), peerStr.c_str(), mtu);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
|
|
||||||
|
// Reset cmd buffer
|
||||||
|
cmd[0] = '\0';
|
||||||
|
|
||||||
|
// Set netmask (/24 CIDR temporarily with raw command, improve later)
|
||||||
|
snprintf(cmd, sizeof(cmd),
|
||||||
|
"ifconfig utun0 netmask 255.255.255.0");
|
||||||
|
system(cmd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user