mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-31 16:14:46 +02:00
Fix issues with relaying and holepunching
This commit is contained in:
parent
4b6985718a
commit
a665e3aae9
5 changed files with 10 additions and 15 deletions
|
@ -97,7 +97,7 @@ export async function pickClientDefaults(
|
|||
|
||||
let subnets = clientsQuery.map((client) => client.subnet);
|
||||
|
||||
// exclude the exit node address by replacing after the / with a site block size
|
||||
// exclude the newt address by replacing after the / with a site block size
|
||||
subnets.push(
|
||||
address.replace(
|
||||
/\/\d+$/,
|
||||
|
|
|
@ -133,7 +133,7 @@ export async function updateHolePunch(
|
|||
|
||||
return res.status(HttpCode.OK).send({
|
||||
destinationIp: site.subnet.split("/")[0],
|
||||
destinationPort: parseInt(site.endpoint.split(":")[1])
|
||||
destinationPort: site.listenPort
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
|
|
|
@ -10,6 +10,7 @@ import config from "@server/lib/config";
|
|||
|
||||
const inputSchema = z.object({
|
||||
publicKey: z.string(),
|
||||
port: z.number().int().positive(),
|
||||
});
|
||||
|
||||
type Input = z.infer<typeof inputSchema>;
|
||||
|
@ -41,7 +42,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const { publicKey } = message.data as Input;
|
||||
const { publicKey, port } = message.data as Input;
|
||||
|
||||
const siteId = newt.siteId;
|
||||
|
||||
|
@ -58,7 +59,6 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||
let site: Site | undefined;
|
||||
if (!siteRes.address) {
|
||||
const address = await getNextAvailableSubnet();
|
||||
const listenPort = await getNextAvailablePort();
|
||||
|
||||
// create a new exit node
|
||||
const [updateRes] = await db
|
||||
|
@ -66,7 +66,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||
.set({
|
||||
publicKey,
|
||||
address,
|
||||
listenPort
|
||||
listenPort: port,
|
||||
})
|
||||
.where(eq(sites.siteId, siteId))
|
||||
.returning();
|
||||
|
@ -79,7 +79,8 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||
const [siteRes] = await db
|
||||
.update(sites)
|
||||
.set({
|
||||
publicKey
|
||||
publicKey,
|
||||
listenPort: port,
|
||||
})
|
||||
.where(eq(sites.siteId, siteId))
|
||||
.returning();
|
||||
|
@ -116,7 +117,6 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||
);
|
||||
|
||||
const configResponse = {
|
||||
listenPort: site.listenPort,
|
||||
ipAddress: site.address,
|
||||
peers
|
||||
};
|
||||
|
|
|
@ -67,13 +67,8 @@ export const handleOlmRelayMessage: MessageHandler = async (context) => {
|
|||
|
||||
return {
|
||||
message: {
|
||||
type: "olm/wg/connect",
|
||||
data: {
|
||||
endpoint: site.endpoint,
|
||||
publicKey: site.publicKey,
|
||||
serverIP: site.address!.split("/")[0],
|
||||
tunnelIP: client.subnet
|
||||
}
|
||||
type: "olm/wg/relay-success",
|
||||
data: {}
|
||||
},
|
||||
broadcast: false, // Send to all olms
|
||||
excludeSender: false // Include sender in broadcast
|
||||
|
|
|
@ -324,7 +324,7 @@ PersistentKeepalive = 5`;
|
|||
|
||||
let payload: CreateSiteBody = {
|
||||
name: data.name,
|
||||
type: data.method
|
||||
type: data.method as any,
|
||||
};
|
||||
|
||||
if (data.method == "wireguard") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue