networking · beginner · ~15 min

Is it a safe test target?

Enforce the authorized-scope rule in code.

Challenge

Implement int safe_test_target(const char *host) returning 1 only if host is a localhost address ("localhost", "127.0.0.1", "::1"); any other host returns 0 (out of scope without authorization).

Starter code

#include <string.h>

int safe_test_target(const char *host) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.