telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

ip.c (615B)


      1 /*
      2  * Telize 2.0.0
      3  * Copyright (c) 2013-2020, Frederic Cambus
      4  * https://www.telize.com
      5  *
      6  * Created:      2013-08-15
      7  * Last Updated: 2019-03-13
      8  *
      9  * Telize is released under the BSD 2-Clause license.
     10  * See LICENSE file for details.
     11  */
     12 
     13 #include "telize.h"
     14 
     15 int
     16 request_ip(struct http_request *req)
     17 {
     18 	char		ip[INET6_ADDRSTRLEN];
     19 
     20 	if (!telize_request_ip(req, ip, sizeof(ip))) {
     21 		http_response(req, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
     22 		return (KORE_RESULT_OK);
     23 	}
     24 
     25 	http_response_header(req, "content-type", "text/plain");
     26 	http_response(req, HTTP_STATUS_OK, ip, strlen(ip));
     27 
     28 	return (KORE_RESULT_OK);
     29 }