Giter VIP home page Giter VIP logo

lipify's Introduction

C library for api.ipify.org

lipify connects to http://api.ipify.org to query your current IP address. Both IPv4 and IPv6 is supported, for connecting to the ipify server and returning your address.

The library weighs in at 14 kiB. A versioned tarball can be downloaded from GitHub: https://github.com/troglobit/lipify/releases

Build & Install

By default, lipify installs to /usr/local:

make
make install

The default can be changed by setting the prefix= variable at install:

make install prefix=/opt

The DESTDIR= variable is also supported, for the benefit of packagers.

Example

The simplest example of lipify looks like this:

    #include <stdio.h>
    #include <ipify.h>

    int main(void)
    {
            char addr[256];

            if (ipify(addr, sizeof(addr)))
                    return 1;

            printf("%s\n", addr);

            return 0;
    }

You can also get a descriptor, to use with poll() or an event loop library like libuEv, like this:

    #include <ipify.h>

    int main(void)
    {
            int sd;
            char addr[256];

            sd = ipify_connect();
            if (sd < 0)
                    return 1;

            if (!ipify_query(sd, addr, sizeof(addr)))
                    printf("%s\n", addr);

            return ipify_disconnect(sd);
    }

License

lipify is free software, licensed to you under the very permissive ISC license. See the file LICENSE in the lipify distribution for details.

Origin & References

lipify is written by Joachim Wiberg, post bug reports and pull requests to the project's GitHub repository at https://github.com/troglobit/lipify

lipify's People

Contributors

troglobit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lipify's Issues

looks like it is copying garbage into |addr|

len might need to be shorter in strncpy(addr, ptr, len);

I got something like this:

(gdb) p ptr
$2 = 0xbfffee61 "95.251.46.206\004\b\b"

(gdb) p len
$3 = 256

This results in it showing garbage in the output:

$ ./ipfiy
95.251.46.206:

or

$ ./ipfiy
95.251.46.206m

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.