* add `is_right_type`, `is_right_protocol` to reduce duplication
* search in GList using `g_list_find_custom` instead of manual iterations
* reduce scope of some variables
Testing Done:
Compiled.
Reviewed at https://reviews.imfreedom.org/r/645/
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.