Comments (6)
Hi @begetan,
I wanted to rewrite my example DHCP server with recently added server.go implementation but found no code for sending packet back to network.
Have a look at server_test.go
, you can send packets back to the network using the conn net.PacketConn
. We definitely need to improve the examples/documentation, which is being tracked in #188.
from dhcp.
Basically what @pmazzini said. I will write examples soon (days hopefully).
Handling errors and messages at the moment can be done implicitly with channels, but I agree that it would be nice to have them explicitly from the handler. I will have a look at that too
from dhcp.
Because of the above, @begetan could you please rename this issue to reflect what has to be done, or close this and reopen a new one? Thanks!
from dhcp.
@pmazzini
I've checked server_test.go and understood you way of handling replies.
Since I am coming to this library from other project I just trying to adopt my code based on current knowledge.
In my point of view there are some quite reasonable abstraction levels for public API:
- DHCP bytes handling - basic functions for protocol bytes manipulation
- DHCP messages packet handling (client/server) - basic functions for creating and investigation of real packets
- Network support (client/server) - helpers to provides Network/OS specific logic
- Server/Client logic - at this level users write their server or client implementation
There is one already open discussion about implementation of 1 and 2 level in library: #186
But here I would like to open another discussion about implimentation of layers 3 and 4.
In my humble opinion it is expectable to have one level functions in the same level of abstraction in code, like conn.ReadFrom and conn.WriteTo. According this logic user handler should get packet for processing and return back new packet to the library.
I just showed an example of separation logic between layer 3 and 4 including Interface method to handle server level configuration. But let's focus on architecture first because it's most important for quite new library. I believe your code implementation is much more professional than other projects and you want to share experience for wide range of programmers. So it should be structured well.
from dhcp.
@begetan Do you mean that the server handler should only be able to craft a response packet and should not receive a net.PacketConn
? If that is the case then I kind of agree.
Can the issue title be properly updated?
from dhcp.
After better thinking and evaluation of current implementation I see no reason to pass global server parameters to user handler. It depends on concurency model and user architecture. But now I am definitely sure about handling only packet structure, not connections.
from dhcp.
Related Issues (20)
- No support for non-apple boot menus? HOT 10
- can you release a version? HOT 5
- Merge insomniacslk/exdhcp into dhcp/examples
- dhcpv4: Where is method `NewOffer` HOT 1
- how to create a dhcp4 server and assign IP address to clients based on subnetmask? HOT 4
- dhcpv4 malformed packet HOT 3
- Existing check that c.ifaceHWAddr == msg.ClientHWAddr HOT 2
- Implement NewIPv6UDPConn for Windows HOT 1
- Construction of offer message by DHCP server HOT 1
- panic parsing UDP packet HOT 2
- Why are we sorting options during Marshal ? HOT 1
- DHCP Options to support RFC8572 SZTP HOT 2
- RFC 1035 Labels: Support Partial Domain Names as per RFC 4704 Section 4.2 HOT 1
- Panic on DiscoverOffer HOT 1
- Writing a DHCPv4 server on Windows. Is it supported? HOT 7
- OptClientArchType does not get the arch field value HOT 3
- IsOptionRequested does not work with GenericOptionCode HOT 4
- 2 byte code length
- Support Windows HOT 3
- Rapid Solicit not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dhcp.