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

Big Fork. #57

Open
UrielCh opened this issue Jul 23, 2019 · 19 comments
Open

Big Fork. #57

UrielCh opened this issue Jul 23, 2019 · 19 comments

Comments

@UrielCh
Copy link

UrielCh commented Jul 23, 2019

Hi,
Thank for this project.

I'm trying to replace my ugly dnsmask configuration + nodejs front, by an pure nodejs solution.
I forked your source for some changes, but I make a loooooooot of changes.
the final version should be a kind of pure typescript router (PAC + http-proxy + dhcp + dynamic public IP switch + live http blocking features)

on the dhcp server the change include:

  • Use async hook, so can use an external database to store lease.
  • Static lease are now reserved.
  • New free lease detection algorithm.
  • Project converted to Typescript.
  • Refactor configuration model.
  • Datastorage can be share and fill by an external live interface.
  • remove auto remove oldest lease.
  • Properly handle Offered lease as non validated lease (that expire within a couples of seconds)
  • Implement DHCPRELEASE
  • Implement DHCP renew
  • Speed improvement
  • Add Tag support (allow tagging Lease to add common options)

I think that this fork solve 3 of the current opened issue.

special:

Maybe we will be able to merge one day, but you will have to switch to typescript.

I plane to deploy a first version next week.

https://github.com/UrielCh/node-dhcp

give me your feedback

@infusion
Copy link
Owner

Hi,

thanks for your ping! Your changes look impressive! The time when I started this project, async code was not a thing. So I'm totally in favor of going a step forward.

I have to test your fork and look into the code in greater detail. But all your improvements are long-awaited and I would look forward integrating these features :) Did you make any cuts in terms of generalizability, which were only useful for your very use-case?

What would be your idea of integrating your fork into the main branch? Can it be seen as a full replacement? If not, would you like to work with me together on bringing these features into the main branch?

Robert

@UrielCh
Copy link
Author

UrielCh commented Jul 23, 2019

Why are you using a dual licence ?
a mix of 2 open licence is unusual.

@infusion
Copy link
Owner

I chose a dual license to match different requirements. Practically, it's MIT, but to embed it into an environment where GPL is used, you can use the GPL part.

@XantheFIN
Copy link

Broken here when try test:

`Error: Cannot find module 'debounce'
Require stack:
- /lib/leaseStore/LeaseStoreFile.js
`

or?

@UrielCh
Copy link
Author

UrielCh commented Jul 24, 2019

extract from package.json:

  "dependencies": {
    "debounce": "^1.2.0",
    "fs-extra": "^8.1.0",
    "minimist": "*"
  }

debonce is here, so maybe you should make a new npm install.

@UrielCh
Copy link
Author

UrielCh commented Jul 24, 2019

I have just finish my heavy refactor.

Leases are now completely new, and leaseStatic support tags, like dnsmask.

@UrielCh
Copy link
Author

UrielCh commented Jul 24, 2019

anyone know how works Options id
150 151 159 160 ?
100 101 120 132 133 ?
I do not knows they types.
I can not find they configuration name.

I use this page to find some data:
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml

But some optionId are vendor dependent ...

some more change and this project will be able to compete old school classic DHCP server.

@XantheFIN
Copy link

I see it had still some typo but now got running. Tried with WinXP laptop and it has still failure to give correct DHCP Offer message so it fails.

@UrielCh
Copy link
Author

UrielCh commented Jul 24, 2019

Okey, you should wait some days, to let me finish my devs.

@XantheFIN
Copy link

Sure! Sorry and thanks.

@UrielCh
Copy link
Author

UrielCh commented Jul 28, 2019

I have just setup the dhcp server, but It do not receved any discover multicast message.
How to be shure that the server listen to the proper network interface (I have 6 ethernet port on my server)

the mail UDP socket is initialied with:
const socket = createSocket({ type: "udp4", reuseAddr: true });

but there is no reference to an interface name.

I make all my developpement on a windows host, the production is is an ubuntu server.

@XantheFIN
Copy link

XantheFIN commented Jul 28, 2019

As far as i know there is no specific interface and you need manually setup IP for that Ethernet port (i mean IP, netmask 255.255.255.0 or same you congifured in config, and router IP).

IP and router IP need be same and same on config file for server.

It listens 0.0.0.0 as to get messages which means all IPv4 messages on host machine... When i originally loaded project there was broken broadcast address which was not passed correctly to dhcp.js file which too made it not working.

And if you try pass via config file ip with assigned mac address it is broken still by this day until mac styling is fixed to be same on everywhere on project (including hard coded test files which uses hyphen styling for not any specific reason as far as i know as linux supports colons too).

@UrielCh
Copy link
Author

UrielCh commented Jul 28, 2019

If I bind socket 10.5.0.1, I do not receive any DHCP Discover.
If I bind socket 10.5.255.255, I do not receive any DHCP Discover.

Update: If I bind socket 0.0.0.0, I receive all DHCP Discover....

My set is:

  • enp1s0 => local
    IP 10.5.0.1
    network 10.5.0.0/16
    gateway None

  • enp2s0 => Internet service provider 1: (xDsl)
    IP 10.12.0.3
    network 10.12.0.0/16
    gateway 10.12.0.1

  • enp3s0 => Internet service provider 2: (coaxial operator)
    IP 192.168.1.225
    network 192.168.1.254/24
    gateway 192.168.1.1

  • enp4s0 => Internet service provider 3: not setup yet (will be 4G)

  • enp5s0 => Internet service provider 4: not setup yet (Will be fiber)

  • enp6s0 => Internet service provider 5: not setup yet (will be an other xDSL)

But I only want to reply to DHCP on enp1s0.
So... maybe I can try to guess the incomming interface for each UDP, in the last case I will filter that with an IPtables.

an Idea ?

@UrielCh
Copy link
Author

UrielCh commented Jul 28, 2019

update it's not multicast but broadcast.
in nodeJs doc only multicast have call to specified an interface

socket.setBroadcast(true); should be the only needed call but it do not work's

to continue my test I use an basic iptables:

iptables -I INPUT -p udp --dport 67 -i '!enp1s0' -j DROP

@UrielCh
Copy link
Author

UrielCh commented Nov 15, 2019

Hi,
I found some time to resume my fork,
the news:

  • This server do not support binding a single interface, the issue Interface binding #37 had never been implemented.
  • I have start a rebuild an ReactJS Backoffice ton configure the dhcp + HTTP Proxy + routing interface.

@aquamoth
Copy link

Any chances you will get this work completed and maybe make an npm package from it?

@UrielCh
Copy link
Author

UrielCh commented Aug 14, 2020

I need a to bind an UDP pour on a specific interface.
I tried with an iptables, but that a nightmare using this way.

I wish deno will support interface binding, so I will move to it.

for now I'm stuck.

@szekelyisz
Copy link

@UrielCh You can use the setsockopt call for that on Unix-like systems, not sure about Windows.

Check out this stackoverflow thread and this package.

@UrielCh
Copy link
Author

UrielCh commented Feb 3, 2023

Thx for the link,

But for now, I'm switching from NodeJS to Deno, So can not check that.

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

No branches or pull requests

5 participants