lib: Add before/after hooks to async_connect