A man peeped through a hole in the door of Messenger of Allah ﷺ's house, and at that time, Messenger of Allah ﷺ had a Midri (an iron comb or bar) with which he was rubbing his head. So when Messenger of Allah ﷺ saw him, he said (to him), "If I had been sure that you were looking at me (through the door), I would have poked your eye with this (sharp iron bar)." Messenger of Allah ﷺ added, "The asking for permission to enter has been enjoined so that one may not look unlawfully (at what there is in the house without the permission of its people)."
أَخْبَرَهُ أَنَّ رَجُلاً اطَّلَعَ فِي جُحْرٍ فِي باب رَسُولِ اللَّهِ ﷺ وَمَعَ رَسُولِ اللَّهِ ﷺ مِدْرًى يَحُكُّ بِهِ رَأْسَهُ فَلَمَّا رَآهُ رَسُولُ اللَّهِ ﷺ قَالَ لَوْ أَعْلَمُ أَنْ تَنْتَظِرَنِي لَطَعَنْتُ بِهِ فِي عَيْنَيْكَ قَالَ رَسُولُ اللَّهِ ﷺ إِنَّمَا جُعِلَ الإِذْنُ مِنْ قِبَلِ الْبَصَرِ