amonroy has asked for the wisdom of the Perl Monks concerning the following question:
Summary: I have a group of CGIs that check a license at runtime. The license is based on the IP of the server and it's stored in an external file. This model has been useful for a while, but I have encountered problems reading the real IP address of the machine because (I believe) the way I read the IP address is based on the hostname. Let me elaborate.
The license string is generated doing an hexdigest of the IP addres and a predefined number. I also check that the IP address is not an internal network IP (such as 10.*.*.*) or the loopback address 127.0.0.1.
Basically the license creation is done like this:
use Sys::Hostname; use Socket; use Digest::MD5; my $hostname = hostname(); my $address = gethostbyname($hostname); my $ip = inet_ntoa($address); my $key = "1234567"; # arbitray number my $md5 = Digest::MD5->new; $md5->add($key, $ip); my $license = $md5->hexdigest;
For checking the license is just the reverse of the above.
My methodology has some problems because sometimes the /etc/hosts resolves the hostname to 127.0.0.1 or to an internal IP instead of the "real" external IP. I obviously don't want to give licenses to internal IPs or the loopback address.
I wish there was a way to know the "real" IP address that the machine has for the exterior world. Question 1: Is there a better way to read the IP address?
Question 2: Have any of you implemented a similar licensing model, what other models have you used?
P.S. I have encrypted my code so the license thing is not easy to read. Although the only way to hide the source code is by deleting it :-) (FAQ).
Pax vobiscum.
-Andrés
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Licensing model for CGIs using IP addres
by Errto (Vicar) on Apr 21, 2004 at 04:06 UTC | |
|
Re: Licensing model for CGIs using IP addres
by Abigail-II (Bishop) on Apr 21, 2004 at 09:17 UTC | |
by amonroy (Scribe) on Apr 21, 2004 at 13:45 UTC | |
|
Re: Licensing model for CGIs using IP addres
by Anonymous Monk on Apr 21, 2004 at 03:37 UTC | |
by Abigail-II (Bishop) on Apr 21, 2004 at 09:31 UTC | |
|
Re: Licensing model for CGIs using IP addres
by coec (Chaplain) on Apr 21, 2004 at 04:16 UTC | |
|
Re: Licensing model for CGIs using IP address
by BigLug (Chaplain) on Apr 22, 2004 at 03:45 UTC |