OSX per app network throughput via nettop - macos

The OSX command line tool nettop (I think it was added with Lion) can display per app network throughput without requiring root privileges. I browsed through the Darwin source code on http://www.opensource.apple.com/ but couldn't find it's source code. Is it open source at all or did I just missed it. Incase the source is not publicly available, does anyone have an idea via which api nettop is getting its data?

nettop is open source only in its BSD version, but Apple's version uses their private NetworkStatistics framework (new in Lion) so I doubt you will find the sources since Apple tends to not release private code.

Related

How to get macos app signing set up for packages

I am new to macOS development and am having a terrible time trying to get my code signed. The documentation to me seems to be horrible.
My specific situation...
I am building a cross-platform app that runs on Linux, Windows, macOS and eventually iOS and Android.
It is a console app that runs as a service or LaunchDaemon
It has a UI served by WebView, http, or console commands depending on the scenario.
It is built with Go 17 in VScode.
I am not using xCode other than the command line tools.
My goal on macOS it to distribute it as a package (pkg) and not as an app.
I have been using MunkiPkg to build it
I am hung up on understanding how the various certificates need to be set up. I have not been able to get a successfully signed package notarized.
Can someone please point me to some documentation that explains how my scenario works? Most of what I found requires it to be built in xCode. And the Apple docs seem mostly to focus on how great their tools are without actually explaining how to use them.
Help!

PF header net/pfvar.h on OSX missing

PF (packet filter) is a kernel-level firewall, included in BSD-like kernels (Darwin kernel is basically BSD), and BSD man pages provide detailed documentation about these headers, letting control PF programmatically. PF is included in OSX kernel, even though it's disabled by default.
I know it's possible to control PF in OSX someway, because applications like Murus exist, providing user-friendly GUI for this low-level "king of firewalls", and this API is not not manual /etc/pf.conf parsing, as I suspected first.
Any way to add these headers and control PF from my OSX applications?
MacOS Sierra 10.12.6
Xcode 9.2 (9C40b)
UPDATE Some information I found, a bit out-of-date though
the <net/pfvar.h> you are looking for is at the link below (for MacOS Mojave and Catalina) - Older versions are also available.
https://opensource.apple.com/source/xnu/xnu-4903.221.2/bsd/net/pfvar.h.auto.html
Here is <net/pfvar.h> for the MacOS Sierra:
https://opensource.apple.com/source/xnu/xnu-3789.70.16/bsd/net/pfvar.h.auto.html
If you need a full working application example, I ported pfctl from BSD to MacOS and compiled it using all the MacOS kernel headers and system libraries. I can upload the full working source-code tree on GitHub for you. Currently I am using it on Catalina, and I can control anything on the PF subsystem. You can then learn from it and use the routines on your app. The code, functions and parameters are simple to understand and can easily meet your needs.

Simple HID OSX Application

I am getting started with coding for HID devices. I got started with reading Apple documents and sample code. The code provided are terribly outdated that it doesn't even open in Xcode8.
Download Sample Code from Apple
I need help in finding a sample project / snippet for getting started with HID Services! Open a handle, read and write reports to device, Listen to reports generated by device in a run loop.
OS X/macOS's HID stack is called IOHIDFamily, and much of it is open source. This includes kernel and userspace components. You can find the code for various different OS X/macOS releases at
https://opensource.apple.com/
For 10.12.2 (latest code released at time of writing) you can browse the IOHIDFamily code here:
https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-870.31.1/
or download it as a zip file here:
https://opensource.apple.com/tarballs/IOHIDFamily/IOHIDFamily-870.31.1.tar.gz
The "tools" directory contains some userspace sample/test code which might help with what you're trying to do.
As for sample code not being updated, documentation being incomplete/outdated/missing, and provided code requiring a lot of effort to build: welcome to Mac systems & driver development. That's unfortunately how it is. I've been doing OS X kernel/driver work for 7 years, and while some things get easier with experience, downloading code from Apple and building it still feels like playing the lottery.

Subversion client for Diff/Compare (Mac)

I'm looking for a (free) subversion client that gives a complete DIFF/Compare between two revisions. Xcode's Source Control comparison tool only compares one file at a time, and doesn't give you a list of files updated between two revisions.
I tried to use svnX, but i'm unable to configure it with my local repository using:
svn+ssh://username#server-machine.local/Users/Path/subversion/ProjectName/
Any suggestions regarding an appropriate subversion client, and/or how to make svnX to work?
The best tool that I have found is subclipse. It is an add on for eclipse but you can use it to manage your repository as well.
Collabnet also offers a product called Collabnet Destktop that includes the subclipse client.
One major caveat is that you have to install the JavaHL library. Make sure to read the OS specific directions!
You might have to play with it a bit but the repository browser is very powerful.
I use svnX in Mac OS 10.7.5, You can download svnX for Max OS X here.
There are some server they provide free/private Space for subversion. I used this free/private space from Assembla
Here is screenShot that shows how to setup svnX in Mac OS X.
In working copy you can see difference in revision. svnX uses fileMerge to show difference. Its one of the best subversion client for mac os x.

Writing code for a Mac using Lazarus

I have done a little work on lazarus' free pascal. So when a client asked me to write an application for a mac, after the initial, "it can't be done" stage. (followed by an asp.net maybe stage) i thought about writing it using lazarus.
Question is. I have only a virtual machine running mac OSX, this means that i do not really want to develop on the mac. However, i just cannot seem to get the applications that i have written in lazarus on windows to work on the mac. I have tried the deployment using the Lazarus Wiki and the MACOS folder is empty and so when i put it on the mac it doesn't run the application.
What is the best way of doing this or am i barking up the wrong tree?
It seems you want to do cross-compiling, which is theoretically possible, but may not be practical, for the reasons mentioned by Marco above.
As an alternative, you could install XCode, FreePascal, and Lazarus on a MacOX machine. You could still do your development and some testing on Windows/Linux. When you hit a certain milestone, you can copy your source code to the Mac and compile your application to test and give to the user.
Even if it were possible to easily cross-compile, there some minor differences between platforms, so (especially if it's a GUI app), you would want to test it on an actual MacOS box before giving it to the client.
I've taken the route described by Noah - and I was incredibly surprised that after about three weeks development on Windows, it took about 10 minutes to get the application running on the Mac.
My route was to install Xcode 4.3 on an old Mac Mini running snow leopard, then install Lazarus using the fink version as described here. This took a while but was done in an evening.
Then I just copied my folder across to the Mac, opened the lpi on the Mac, compiled it. It failed so I removed a windows references, recompiled, and it was working. I was truly amazed.
What linker and assembler do you use to generate binaries? To my best knowledge the linker for recent OS X versions is not available in source.
Afaik what you want (crosscompiling to Mac) is not possible for recent versions (and I've done it for PowerPC myself in the past).
The easiest is to use the Unix "file" command on the binary to see what is generated, and make sure it reads something with "MachO" in it. Easiest is if you have a Linux install (where this command is pretty standard), but versions can be found for windows too (cygwin, mingw and 3rd party)

Resources