telize

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

ip.c (659B)


      1 /*
      2  * Telize 3.1.0
      3  * Copyright (c) 2013-2021, 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  * SPDX-License-Identifier: BSD-2-Clause
     13  */
     14 
     15 #include "telize.h"
     16 
     17 int
     18 request_ip(struct http_request *req)
     19 {
     20 	char		ip[INET6_ADDRSTRLEN];
     21 
     22 	if (!telize_request_ip(req, ip, sizeof(ip))) {
     23 		http_response(req, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
     24 		return (KORE_RESULT_OK);
     25 	}
     26 
     27 	http_response_header(req, "content-type", "text/plain");
     28 	http_response(req, HTTP_STATUS_OK, ip, strlen(ip));
     29 
     30 	return (KORE_RESULT_OK);
     31 }