Firewall status tray icon - firewallstate-2.1

Configuration wizards, scanners, remote desktop, etc.
Message
Author
User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#21 Post by tasmod »

Version 0.8 released.

has added info to menu item 'Version information'

I'm working on an all C solution using curl for the IP reporting. Right now it runs a small script.


Billtoo,

Icewm
Yes, this report means libgio is missing.

Because I have so much installed on my machine it is hard to know what else is required for firewallstate to work for someone else.

You should be able to download it from package manager.

fatdog 64,
looks like a gtk version problem or tray is different
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#22 Post by vovchik »

Dear Rob,

Version 0.8 introduces three unnecessary dependencies:

libkrb5support
libgssapi_krb5
lincurl_gnutls

There are easier ways to get the external IP, e.g.:

wget -qO- whatismyip.org

I would revert to the v. 0.7 way of doing things and add the above line in a system call for simplicity's sake.

With kind regards,
vovchik

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#23 Post by tasmod »

vovchik, that is how it's done.

it may be that because I listed libgio as a dependency it is asking for them.

I have a CURL routine that is not working correctly, it won't write to the file. So as a temporary fix i made a call to an external bash script.

Code: Select all

{  /* Get your IP address from tmp file */

   fp = (FILE *)popen("cat /tmp/ipis.txt |  awk '{print $1}'  " , "r" );

    fgets(ipis,sizeof ipis,fp);
    pclose(fp);
    
}
script

Code: Select all

#!/bin/bash

`wget -O /tmp/ipis.txt -q icanhazip.com`
echo "`cat /tmp/ipis.txt`"    #A test
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#24 Post by tasmod »

This is the CURL section that won't play ball, I'm sure I have something wrong in write_data

All this and two lines in bash does it :-

Code: Select all

/*//////////////////////////////////////////////////* For the CURL routine below */

static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
  int written = fwrite(ptr, size, nmemb, (FILE *)stream);
  return written;
}
 


///////////////////////////////////////////////////// Should run IP routine but doesn't write

*/
gboolean ISip(gpointer ptr);

gboolean ISip(gpointer ptr)   {      //Create file, write returned IP and then open file and read.
   
CURL *curl;
	 
curl = curl_easy_init();

if(curl) {
fp =(FILE *) fopen("/tmp/ip.txt","w");
curl_easy_setopt(curl, CURLOPT_URL, "http://www.icanhazip.com");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);

curl_easy_cleanup(curl);

fclose(fp);
}

{

fp =(FILE *) fopen("/tmp/ip.txt","r");

 fgets(ipresult,sizeof ipresult,fp);

 fclose(fp);

}
}


Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#25 Post by tasmod »

Arghhhh, just realised I left the #include <curl/curl.h> in the code and I may have another lib missing so the curl won't work anyway. :evil: :evil:

Thanks vovchik, I will remake the pet.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#26 Post by tasmod »

Version 0.9 with removed lib call and added Network IP to reporting
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#27 Post by vovchik »

Dear Rob,

Yep, you got rid of the curl dependencies nicely and it all works except of the local IP, which is wrong. In my case it shows 192.168.1.0 as the local network, when, in actual fact, it is 192.168.2.x. Look at the way I did it in ipinfo - which you scrapped because it's not in all puppies. I also did another checkip prog
http://www.murga-linux.com/puppy/viewto ... 02&t=56678 that checks the entire local network, but you probably don't want to use that because it takes 45 secs to get all live IPs on a LAN (ping takes over 4 minutes!). However, there is probably a routine in it that just grabs the local machine IP expenditiously. I can't remember.

Nice work.

With kind regards,
vovchik

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#28 Post by tasmod »

Hi vovchik,

Yes, I removed the ipinfo as I wasn't sure if it would work with earlier puppys. I also didn't want to force on someone another app in the pet, rather just make a call to it from code.

Network IP is not the machines own ip but the base ip of the router.

Seems no-one wants that.

OK I believe there is a list of connected pcs in /etc/hosts. However I can only print one so far to the Version Information , I'm not sure yet how to make additional lines display, all calls stop at single line when newline is met in the array. i need to trap them out then re-insert during display.
I've been working on that one but for now was happy to just have a working app.

Micko reports that the report-video just flashes on briefly in the luci version. I can't get it to do that, it works for me.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#29 Post by big_bass »

vovchick you posted this on the other page I like that

Code: Select all

#!/bin/sh
myfile="$@"
gcc `pkg-config --cflags --libs gtk+-2.0` -o "$myfile" "$myfile".c
strip "$myfile"

I had some fun with it and added a little cream to your strawberry dessert :D
you can compile the c code in this thread with it

Code: Select all

#!/bin/sh

# drag N drop c compiler 
# gcc  compiler flags config by vovchick 
# file filters , Xdialog and gcc version checking by big_bass
# 7-19-2010 

MY_CFILE="$@"
DIR_N=`dirname "$@"`
MY_FILE=`basename "$@" .c`



#check gcc version 
gcc_version=`gcc -dumpversion`



Xdialog --title "gcc version" \
        	     --infobox "\ngcc version $gcc_version\n" 0 0 2000



if echo `basename "$@"` | grep -q '.c$'; then
Xdialog --wrap --title "COMPILE" \
        --yesno "Do you want to compile  $@  " 0 0

case $? in
  0)
    echo "Yes chosen."
	
  gcc `pkg-config --cflags --libs gtk+-2.0` -o  "$DIR_N"/"$MY_FILE" "$MY_CFILE"  
    strip "$DIR_N/$MYFILE"
	;;
  1)
    echo "No chosen."
    exit
	;;
  255)
    echo "Box closed."
    exit
	;;

esac

Xdialog --title "Complete" \
        	--infobox "\nConversion to $MY_FILE bin has finished.\n" 0 0 4000

else

 


Xdialog --title "ERROR MESSAGE  drag N drop" \
	    --msgbox "only C code allowed  " 0 0

case $? in
  0)
    echo "OK"
	exit
	;;
 
 255)
    echo "Box closed."
	exit
	;;
esac
 					  
fi				  
		
Attachments
c-compiler.tar.gz
(652 Bytes) Downloaded 1152 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#30 Post by vovchik »

Dear Joe,

Thanks....

I like that.

With kind regards,
vovchik

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#31 Post by tasmod »

Version 1.0 and also Luci specific Version 0.4 released.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#32 Post by big_bass »

Hey tasmond
thanks for posting the C source because you did I was able to locate
an error I had
line 109 had a string compare for /etc/rc.d/rc.local
and since I had a comment I wrote in that file the compare failed


that was a unique problem to slaxer_pup and TXZ_pup that is now fixed
since I use TXZ formatted packages and slack-desc for my build this is the official "your official"
http://www.puppy2.org/slaxer/firewallst ... 3_SLXR.txz



easy fix I just cleaned the file back to the default

Code: Select all

echo '#this file called from rc.sysinit
#you can edit this file
#When firewall is installed, will append lines to this file...
#--------------------------------------------------------------'>/etc/rc.d/rc.local

and your latest Version 1.0 is confirmed to work now with that small patch

can we get the new state to refresh without restarting X ?
I tried a small app that I used many times called refresh X
but it doesnt update jwm I'll keep at that refreshing part till I figure out how

P.S firewallstate-1.0 you should put a "-" symbol in the package name to maintain the package standard

nice app 8)
Joe

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#33 Post by tasmod »

Hi Joe,

I'm somewhat confused as to what is happening re X for you.

Are you saying any firewall state change is not reflected immediately by the icon?

It should be virtually instant to the user. The check routine runs every few milliseconds. I thought originally the routine would hog any processor but it doesn't go above 1% and it's probably less as that's the lowest figure htop can report.

I checked for the line in rc.local as that is appended / removed depending on the firewall install and if my original on/off pet is used.
(I wrote it a while ago to turn firewall on/off when testing)

I borked my Slaxerpup install and need to install it again to check -1's operation with it.

Sorry re the naming convention, it only takes one slip when making the pet and it's in there!

I'm working on 1.1 as I've realised I've only a wired connection here and a wireless connection is not catered for in network address report, it uses ifconfig. I need iwconfig checking as well.
I need my garage laptop back in to check the wireless setup, I use it in there on wireless when I'm playing with my car ecu.

I also need to add more file 'not exist' error checking. It's OK making it work on my machine but I have loads installed on here that can affect the running of firewallstate. What works for me may not for others.
I have the devx and other libraries loaded, so I'm now checking it all out on a fresh frugal install on another laptop.

My next learning step is separate c and h files with 'make' but I'm not sure where to go just yet. I don't know what can be hived off and what is needed left in the 'interval' routine. Or even how to deal with them in code as I'm still unsure of 'static' 'void' etc uses.

I'm looking for a good online primer, I have some which are good on some features of C and others that are good on different features.
It's tiring going back and forth between them and trying to understand.

I'm on the steep part of the learning curve right now and as computers are a lone hobby there's only the net to ask.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#34 Post by big_bass »

Hey Rob (tasmond)
Are you saying any firewall state change is not reflected immediately by the icon?
yes

X has to be restarted to show the change state from on to off

*side note : there was a problem with a mouse cursor program that trio wrote that
x refresh fixed instead of restart X its a small bin I made a pet a while ago



Joe

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#35 Post by 01micko »

Hi Rob

Using your luci version 0.4 in luci-213 I get this error in /tmp/xerrs.log

Code: Select all

rxvt: "report-video": malformed option.
rxvt-unicode (urxvt) v9.05 - released: 2008-06-15
options: xft,styles,combining,blink,encodings=eu+vn,transparent,tint,XIM,frills,
selectionscrolling,wheel,slipwheel,smart-resize,cursorBlink,pointerBlank,scrollbars=plain+rxvt
Usage: rxvt [-help] [--help]
 [-display string] [-tn string] [-geometry geometry] [-C] [-iconic]
 [-cd string] [-/+rv] [-/+ls] [-/+j] [-/+ss] [-/+ptab] [-/+sb] [-/+sr] [-/+st]
 [-sbt number] [-/+si] [-/+sk] [-/+sw] [-/+ip] [-/+tr] [-tint color]
 [-sh number] [-/+ut] [-/+vb] [-/+tcw] [-/+insecure] [-/+uc] [-/+bc] [-/+pb]
 [-bg color] [-fg color] [-hc color] [-cr color] [-pr color] [-pr2 color]
 [-bd color] [-fn fontname] [-fb fontname] [-fi fontname] [-fbi fontname]
 [-/+is] [-im name] [-pt style] [-imlocale string] [-imfont fontname]
 [-name string] [-title string] [-n string] [-sl number] [-embed windowid]
 [-depth number] [-/+override-redirect] [-pty-fd fileno] [-/+hold] [-w number]
 [-b number] [-/+bl] [-lsp number] [-/+sbg] [-mod modifier] [-/+ssc] [-/+ssr]
 [-e command arg ...]
If I use Icewm I get it twice! (this is because for icewm, it needs to be killed and restarted to display correctly in the tray, it's an ice thing :wink: )

"report-video" is working though.. I'm just wondering why it's trying to execute (as I understand it, could be wrong) at the initiation of firewallstate.

If the error is nothing, I can suppress it, however I believe it's harmless but not nothing.

Cheers

Mick
Puppy Linux Blog - contact me for access

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#36 Post by tasmod »

Version 0.5 should fix that.

I have both ready for pets, they now have icons in the menu.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

Disappears from the tray

#37 Post by bigpup »

Disappears from the tray after about 10 to 15 minutes.
Is it suppose to do that?

Installed in Lucid Puppy.

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#38 Post by tasmod »

Hmmm, no. I don't know why that is, there's no timer involved. I've not had that, will monitor on spare PC.

Try version 1.1 it looks nicer on menu anyway and has some code changes in background.

I've dropped the Luci only version as there may be changes in way they want to get video.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#39 Post by tasmod »

'Information' in Lighthouse Pup Mariner 5 with XFCE window manager.
Attachments
lhp5xfce.png
(19.6 KiB) Downloaded 2188 times
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
chrome307
Posts: 708
Joined: Thu 15 Jan 2009, 11:00

#40 Post by chrome307 »

Image

Thanks for this :)

It works for me using Browserlinux 3.54.

I have also noticed that it disappears after a short period of time but will reappear if you select it via the menu. ( firewallstate-1.1 )

I would have like it to remain as a permanent fixture to remind me that the firewall is activated.
Last edited by chrome307 on Tue 27 Jul 2010, 09:28, edited 1 time in total.

Post Reply