saviorand / lightbug_http

Simple and fast HTTP framework for Mojo! 🔥
MIT License
582 stars 37 forks source link

DRAFT: Add functions to get peer name for raddr. #24

Closed thatstoasty closed 7 months ago

thatstoasty commented 7 months ago

Hey @saviorand! I was working on porting over some of the net package for Go and was able to get the peer name for a connected socket. I figured you might want to incorporate it into your library for raddr, but I am not sure where the functions should live within your code.

I'm trying to test it with the latest code from main, but it seems like SysNet is running into some issues. The compiler says:

error: 'self.__lc' is uninitialized at the implicit return from this function
    fn __init__(inout self):
saviorand commented 7 months ago

Ah thanks, will try this out tomorrow. Cool that you're porting over net , I tried doing this at some point when making Lightbug, but quickly gave up. You're stronger tho, best of luck with this 😅

thatstoasty commented 7 months ago

No prob! And I'm sure I'm running into the same challenges you did haha. The net package is extra confusing, only working with TCP connections and listeners for now.

saviorand commented 7 months ago

Actually, works on my machine 😅 just pulled from your branch and ran mojo lighbug.🔥 and mojo bench.mojo. Might be that it now works after a couple updates in main, not 100% sure. If everything looks OK to you I'll merge

thatstoasty commented 7 months ago

Oh nice! It might be that it was failing because I'm running the nightly mojo build on my laptop. I'll remove the print statement. Do you want me to move those functions to some other file? I just dropped them in place to test it out.

saviorand commented 7 months ago

@thatstoasty ah, good point about the functions. As they're more or less generic let's move them to the top-level net which hosts net-related utils -- I already have e.g. the split_host_port there . I prefer not to keep separate "utils" folders to keep the code closer to where it will actually be used. As soon as you can move them I'll merge. About the nightly, I'll test out more after merging. Hopefully I can get a fix in before the nightly becomes an actual release and everything breaks, haha.

thatstoasty commented 7 months ago

@saviorand I moved over the functions, should be good to go if you want to run it one more time to make sure nothing blew up prior to merging 👍

saviorand commented 7 months ago

Yup, works perfectly for me. Merging now, thanks a lot for this!!