pguyot / Einstein

NewtonOS running on other operating systems
GNU General Public License v2.0
409 stars 57 forks source link

Inbound TCP/IP support #96

Open mwvaughn opened 3 years ago

mwvaughn commented 3 years ago

Basic Information

Description of issue

I've managed to get the PCMCIA networking stack running for accessing the Internet from my emulated Newton, but I am unable to access services running on the Newton from my localhost. Specifically, I am trying to get an NPDS server running under Einstein. Specifically, I get a connection refused error when I try to access my Newton's nascent HTTP server.

Expected behaviour

I am able to visit http://localhost:8080 (which is what I have the NPDS server configured to use) and receive a response.

Steps to reproduce issue

  1. Install network packages
  2. Configure Internet to use host IP, mask, and DNS with PCMCIA Ethernet Card
  3. Install NPDS and configure it to use port 8080
  4. Start the NPDS server
  5. Visit http://localhost:8080 in a browser
MatthiasWM commented 3 years ago

The current version has no inbound TCP/IP support. Sorry.

mwvaughn commented 3 years ago

Thanks, Matthias. I'm one of the original NPDS devs and I was hoping (against all odds) for a miracle on this front!

MatthiasWM commented 3 years ago

I'll check if it is possible to implement this. No promises ;-)

pguyot commented 3 years ago

Hello @mwvaughn! I think at some point I tried and got something to work, maybe when I worked on SSL. I'll have a look now that @MatthiasWM has merged his work into the master branch.

mwvaughn commented 3 years ago

Awesome! I am happy to test any time.

pguyot commented 3 years ago

I confirm it does work, using documentation from 2010 and some help from an article about getting similar results with qemu :-)

Screenshot 2021-03-15 at 22 50 08

To get this working in 2021 on an Intel mac running BigSur, I had to:

  1. Install tap & tun kernel extensions, notarized, from https://github.com/Tunnelblick/Tunnelblick/tree/master/third_party (this is the bit that wouldn't work on M1 Mac, I guess)
  1. Fix permissions as per 2010 doc:

    sudo chmod ugo+rw /dev/tap0
  2. Create a bridge interface:

    sudo ifconfig bridge1 create
    sudo ifconfig bridge1 192.168.100.1/24
    sudo ifconfig bridge1 addm en0
  3. Configure pf (instead of ipfw in 2010):

    echo "nat on en0 from bridge1:network to any -> (en0)" > pf-config
    sudo pfctl -F all
    sudo pfctl -f pf-config 
  4. Configure and start the DHCP server Create /etc/bootpd.list with:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>bootp_enabled</key>
        <false/>
        <key>dhcp_enabled</key>
        <array>
            <string>bridge1</string>
        </array>
        <key>netboot_enabled</key>
        <false/>
        <key>relay_enabled</key>
        <false/>
        <key>Subnets</key>
        <array>
            <dict>
                <key>name</key>
                <string>VM NAT Network (192.168.100.0/24)</string>
                <key>net_mask</key>
                <string>255.255.255.0</string>
                <key>net_address</key>
                <string>192.168.100.0</string>
                <key>net_range</key>
                <array>
                    <string>192.168.100.2</string>
                    <string>192.168.100.254</string>
                </array>
                <key>allocate</key>
                <true/>
                <key>dhcp_router</key>
                <string>192.168.100.1</string>
                <key>dhcp_domain_name_server</key>
                <array>
                    <string>8.8.8.8</string>
                </array>
            </dict>
        </array>
    </dict>
    </plist>

Start the server in foreground with:

sudo /usr/libexec/bootpd -D -d
  1. Start Einstein (master branch, after Steve's latest commit)

  2. Select the TAP Network driver

  3. Configure the other end of the bridge interface with:

    sudo ifconfig bridge1 addm tap0
  4. Install the 5 Internet packages on Einstein, configure Internet connection, experience a bug with the PCMCIA network card producing a -48807. Install NPDS package as well as GIF Server.

  5. Connect with Safari on the IP address provided by the DHCP server (192.168.1.20).

Now, we can keep this ticket open for a long-term goal that would be to get Internet servers available in user-mode networking. Something emulators usually perform by defining a port mapping (you tell the emulator to listen on port X and forward to port Y to the guest).

MatthiasWM commented 3 years ago

On 3/15/2021 11:07 PM, Paul Guyot wrote:

I confirm it does work, using documentation from 2010 https://github.com/pguyot/Einstein/blob/master/Emulator/Network/TTapNetwork.h#L37 and some help from an article https://rambling-ideas.salessandri.name/setup-nat-network-for-qemu-in-mac-osx/ about getting similar results with qemu :-)

Oh wonderful! Yes, the Tap approach has some real advantages. I am glad that my merge did not accidentally trample any of your code and it still works.

INDIGI-CO-UK commented 3 years ago

On 15 Mar 2021, at 23:23, Matthias Melcher @.***> wrote:

On 3/15/2021 11:07 PM, Paul Guyot wrote:

I confirm it does work, using documentation from 2010 https://github.com/pguyot/Einstein/blob/master/Emulator/Network/TTapNetwork.h#L37 and some help from an article https://rambling-ideas.salessandri.name/setup-nat-network-for-qemu-in-mac-osx/ about getting similar results with qemu :-)

Oh wonderful! Yes, the Tap approach has some real advantages. I am glad that my merge did not accidentally trample any of your code and it still works.

  • Matthias

So, will be possible to make NPDS fully working on Einstein?

If ‘yes’ then I do not have words to describe your genius, guys! :)

Cheers, Pawel

pguyot commented 3 years ago

Yes, it does work, and it probably has been working since 2010.

INDIGI-CO-UK commented 2 years ago

What is the current state of this ticket? Do I still need to do that 'magic' things from Paul's post in MacOS to make NPDS work 'both ways' or is it now implemented in the new version of Einstein?

MatthiasWM commented 2 years ago

Incoming TCP connections work on what I can the "native" or "cocoa" version of Einstein on macOS. It does require installing all the drivers that Paul listed up here.

I will leave this open until I have a chance to copy Paul's comments somewhere into the documentation.

The FLTK version of Einstein will not honour incoming requests, and there is no plan to implement it.