Which MySQL datatype to use for an IP address? [duplicate]

Since IPv4 addresses are 4 byte long, you could use an INT (UNSIGNED) that has exactly 4 bytes: `ipv4` INT UNSIGNED And INET_ATON and INET_NTOA to convert them: INSERT INTO `table` (`ipv4`) VALUES (INET_ATON(“127.0.0.1”)); SELECT INET_NTOA(`ipv4`) FROM `table`; For IPv6 addresses you could use a BINARY instead: `ipv6` BINARY(16) And use PHP’s inet_pton and inet_ntop … Read more

Single role multiple IP addresses in Spring Security configuration

Your for loop results in following configuration: @SuppressWarnings(“ALL”) @Configuration @EnableWebSecurity public class MyWebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers(“/admin/**”).access(“hasRole(‘admin’) and hasIpAddress(‘127.0.0.1’)”) .antMatchers(“/admin/**”).access(“hasRole(‘admin’) and hasIpAddress(‘192.168.1.0/24’)”) .antMatchers(“/admin/**”).access(“hasRole(‘admin’) and hasIpAddress(‘0:0:0:0:0:0:0:1’)”); } //some other configurations } So for URL: http://localhost:9595/admin/checkappeals/211 only the first matcher is considered, see HttpSecurity#authorizeRequests: Note that the … Read more

Can I send webrequest from specified ip address with .NET Framework?

You need to use the ServicePoint.BindIPEndPointDelegate callback. http://blogs.msdn.com/b/malarch/archive/2005/09/13/466664.aspx The delegate is called before the socket associated with the httpwebrequest attempts to connect to the remote end. public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount) { Console.WriteLine(“BindIPEndpoint called”); return new IPEndPoint(IPAddress.Any,5000); } public static void Main() { HttpWebRequest request = (HttpWebRequest) WebRequest.Create(“http://MyServer”); request.ServicePoint.BindIPEndPointDelegate = new … Read more

Integer to IP Address – C

You actually can use an inet function. Observe. main.c: #include <arpa/inet.h> main() { uint32_t ip = 2110443574; struct in_addr ip_addr; ip_addr.s_addr = ip; printf(“The IP address is %s\n”, inet_ntoa(ip_addr)); } The results of gcc main.c -ansi; ./a.out is The IP address is 54.208.202.125 Note that a commenter said this does not work on Windows.