Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc add zfw calls 1.3.x #1054

Merged
merged 18 commits into from
Jan 7, 2025
Merged

Rc add zfw calls 1.3.x #1054

merged 18 commits into from
Jan 7, 2025

Conversation

scareything
Copy link
Member

changes from #1000 applied to main instead of release-1.x

@scareything scareything force-pushed the rc-add-zfw-calls-main-2 branch from 61119a2 to 5b99de0 Compare December 3, 2024 23:48
@scareything scareything marked this pull request as ready for review December 5, 2024 22:17
@scareything scareything requested a review from a team as a code owner December 5, 2024 22:17
@@ -78,6 +79,28 @@ static bool is_host_only();
static void run_tunneler_loop(uv_loop_t* ziti_loop);
static tunneler_context initialize_tunneler(netif_driver tun, uv_loop_t* ziti_loop);

#if __linux__
static void diverter_quit();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make these into diverter interface

char *diverter_env_path = getenv("ZFW_OBJECT_PATH");
if(diverter_env_path && strlen(diverter_env_path)){
diverter_path = diverter_env_path;
sprintf(zfw_path, "%s/%s", diverter_env_path, "zfw");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use snprintf

static void diverter_update(const char *ip, uint8_t prefix_len, uint16_t lowport, uint16_t highport, const char *protocol, const char *service_id, const char *action) {
int rndm;
uv_random(NULL, NULL, &rndm, sizeof(rndm), 0, NULL);
unsigned short random_port = 1024 + rndm % (65535 - 1023);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if port is in use?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for zfw in tunnel mode it just cant be set to 0. A setting of 0 indicates that a matching packet should be passed to the OS and not to directly forwarded to the ziti0 interface. As long as it between 1 and 65535 it does not matter if it is in use. We could make it any static value between 1 and 65535 and remove the uv_random call. On ziti-router in tproxy mode it would matter that it was specific to the tproxy port configured for the service.

@scareything scareything force-pushed the rc-add-zfw-calls-main-2 branch 2 times, most recently from fea9b96 to df94a2a Compare December 16, 2024 14:27
@scareything scareything force-pushed the rc-add-zfw-calls-main-2 branch from df94a2a to d363b83 Compare January 3, 2025 19:26
@scareything scareything changed the title Rc add zfw calls 1.2.x Rc add zfw calls 1.3.x Jan 3, 2025
}
}
}
else if(svc->Permissions.Bind){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be else? Both permissions could be set

@scareything scareything merged commit ca54079 into main Jan 7, 2025
13 checks passed
@scareything scareything deleted the rc-add-zfw-calls-main-2 branch January 7, 2025 15:20
@scareything scareything mentioned this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants