Giter Site home page Giter Site logo

Comments (12)

sdaubert avatar sdaubert commented on June 13, 2024 1

I've made a fix on branch issue41. Plesase, could you test it?

from packetgen.

sdaubert avatar sdaubert commented on June 13, 2024 1

As said here, I cannot accept #42 for now. I have modified current PR to add OS X's loopback interface detection. Does it suit you?

from packetgen.

sdaubert avatar sdaubert commented on June 13, 2024 1

@picatz My last proposal is not good. Forget it...

from packetgen.

sdaubert avatar sdaubert commented on June 13, 2024

@picatz I don't known OS X. AF_PACKET is used to get MAC address from an array returned by NetworkInterface.addresses. Is there no Ethernet on OS X ?

from packetgen.

picatz avatar picatz commented on June 13, 2024

I was also relatively confused last night when I made the issue.

However, upon some google'n I seem to have found the Socket constant I want to work with on OSX.

Socket

AF_LINK

Link layer interface. Works on osx, and macos stuff.

AF_PACKET

Direct link-layer access. Works on linux.

Example

[1] pry(main)> require 'socket'
=> true
[2] pry(main)> Socket::AF_LINK # works on macos
=> 18
[3] pry(main)> Socket::AF_PACKET # no dice!
NameError: uninitialized constant Socket::AF_PACKET
Did you mean?  Socket::AF_CNT
from (pry):3:in `__pry__'

How to Fix

Maybe some sort of method to get the mac address if the other way fails, or a platform check?

def mac_addr
  begin
    Socket::AF_PACKET # linux
  rescue
    Socket::AF_LINK # macos
  end
end

from packetgen.

picatz avatar picatz commented on June 13, 2024

The mac address checking worked! But, funny enough, the iface was also not being set properly!

I made a pull request #42 that works for me.

from packetgen.

picatz avatar picatz commented on June 13, 2024

Ah, I see. So I can see that it's now catching my lo0 loopback by default now.

But, I don't think this really gives me the desired results I'd want for the shell, right? Assumably, it would just load up and be read to rock and roll with my en0 ( my default ) interface when I pull up pgconsole.

In the original code, wasn't it looking originally for the first interface that wasn't lo? So, wouldn't we want, like, the opposite of the match at first? Then, if that's gone horribly wrong, we use loopback as the default?

from packetgen.

sdaubert avatar sdaubert commented on June 13, 2024

@picatz good point, we don't want to use a loopback interface in the shell.

from packetgen.

picatz avatar picatz commented on June 13, 2024

@sdaubert Hopefully I did this right: efa5adc

Did the editing on the github website. Haven't done that before. So, I dunno. But, yeah. Works on my end! 😂

from packetgen.

picatz avatar picatz commented on June 13, 2024

Also, I realized I have my debug line still in the pgconsole in those commits.

😅 Should that be removed?

from packetgen.

sdaubert avatar sdaubert commented on June 13, 2024

@picatz yes, you can remove it by making a new commit ;-)

from packetgen.

picatz avatar picatz commented on June 13, 2024

Removed it: 34f7a49

from packetgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.