All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Your fasting is correct because smelling those discharges is not among the things which invalidate the fasting, because fasting is only invalidated by what enters the stomach by mouth or nose; for more benefit, please refer to Fatwa 85377.
Smelling those discharges does not lead to anything entering the stomach.
As regards the ruling of such an act, this is permissible if it was for a need, but if it was without a need, then it is better to avoid it.
You should know that these discharges invalidate ablution, so if you continuously have them, you should perform ablution for every prayer after its prescribed fixed time begins.
For more benefit, please refer to Fataawa 107530, 103316, 104794 and 93596.
Allaah Knows best.