I know we can easily redirect a path to another path with Redirect module, but what I want to do is more complicated, my condition is when the user has a specified IP and the route is matched with to a specified path redirect it.

Pseudo code what I'm looking for is

if $path='xxxxx' and $user_ip = 'yyy.yyy.yyy.yyy' redirect to 'zzzzz'

how I can implement this, what I need is where is the best place to implement this?