This file is indexed.

/usr/share/amsn/msnp2p/session_manager.tcl is in amsn-data 0.98.9-1ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
namespace eval ::p2p {

	snit::type P2PSessionManager {

		variable sessions -array {}
		variable trsp_mgr ""
		option -handlers {}

		constructor {args} {

			$self configurelist $args
			::Event::registerEvent p2pBlobReceived2 all [list $self On_blob_received]
			::Event::registerEvent p2pBlobSent2 all [list $self On_blob_sent]
			::Event::registerEvent p2pChunkSent all [list $self On_chunk_sent]
			::Event::registerEvent p2pChunkTransferred all [list $self On_chunk_received]

		}

		destructor {

                        $self configurelist $args
                        catch {::Event::unregisterEvent p2pBlobReceived2 all [list $self On_blob_received]}
                        catch {::Event::unregisterEvent p2pBlobSent2 all [list $self On_blob_sent]}
                        catch {::Event::unregisterEvent p2pChunkSent all [list $self On_chunk_sent]}
                        catch {::Event::unregisterEvent p2pChunkTransferred all [list $self On_chunk_received]}

                }

		method transport_manager { } {

			if { $trsp_mgr == "" } {
				set trsp_mgr [P2PTransportManager %AUTO%]
			}
			return $trsp_mgr

		}

		method register_handler { handler_class} {

			set options(-handlers) [lappend options(-handlers) $handler_class]

		}

		method Register_session { session} {

			set sid [$session cget -id]
			set sessions($sid) $session
			status_log "Registering $session on $sid"

		}

		method Unregister_session { session } {

			status_log "Unregistering session [$session cget -id]"
			set sid [$session cget -id]
			catch {array unset sessions $sid}
			#$trsp_mgr delete_blobs_of_session [$session cget -peer] $sid
			if { [$self Search_session_by_peer [$session cget -peer]] == "" } {
				$trsp_mgr close_transport [$session cget -peer]
			}

		}

		method On_chunk_sent { event chunk blob } {

			set sid [$chunk get_field session_id]
			#$self configure -session_id $sid
			if { $sid == 0 } {
				return
			}
			set session [$self Get_session $sid]
			if { $session == "" } {
				return
			}
			$session On_data_chunk_transferred $chunk $blob
			#catch {$chunk destroy}

		}

		method On_chunk_received { event chunk blob } {

			set sid [$chunk get_field session_id]
			set session [$self Get_session $sid]
			::Event::fireEvent p2pChunkReceived2 p2pSessionManager $session $chunk $blob
			#catch {$chunk destroy}

		}

		method Get_session { sid } {

			if { [lsearch [array names sessions] $sid ] >= 0 } {
				return $sessions($sid)
			}
			return ""

		}

		method Search_session_by_call { cid } {

			foreach sid [array names sessions] {
				set session $sessions($sid)
				if { [info commands $session] == "" } {
					#Stale session, unregister
					catch {array unset sessions $sid}
					continue
				}
				if { [$session cget -call_id] == $cid } {
					return $session
				} 
			}
			return ""

		}

		method Search_session_by_peer { peer } {

			foreach session [array names sessions] {  
                               if { [info commands $session] == "" } {
                                        #Stale session, unregister
                                        catch {array unset sessions $sid}
                                        continue
                                }
				if { [$session cget -peer] == $peer } {
					return session
				}
			}
			return ""

		}

		method On_blob_received { event blob } {

			#if { [catch {set session [$self Blob_to_session $blob]} res] } {
			#  status_log "Error: $res"
			#  return 0
			#}
			if { [catch {set session [$self Blob_to_session $blob]}]} {
				status_log "ERROR: Cannot get this blob's session ID!!!"
				return
			}
			if { $session == "" } {
				if { [$blob cget -session_id] != 0 } {
					#TODO: send TLP, RESET connection
					status_log "No session!!!!!"
					return
				}
				set slp_data [$blob read_data]
				set msg [SLPMessage build $slp_data]
				$msg configure -application_id [$blob cget -application_id]
				set sid [[$msg body] cget -session_id]

				if { $sid == 0 } {
					status_log "SID shouldn't be 0!!!" black
					catch {$msg destroy}
					return
				}
				
				status_log "Message is [$msg info type] and the body is [[$msg body] info type]"
				set tempses [$self Search_session_by_call [$msg cget -call_id]]
				if { $tempses != "" } {
					set session $tempses
				} elseif { [$msg info type] == "::p2p::SLPRequestMessage" } {
					set peer [$msg cget -frm]
					status_log "Received session request from $peer"
					foreach handler $options(-handlers) {
						status_log "Trying $handler for [[$msg body] cget -euf_guid]"
						if {[$handler Can_handle_message $msg] } {
							#@@@@@@ p2pv2: $guid!!!
							set session [$handler Handle_message $peer "" $msg]
							if { $session != "" } {
								status_log "Got session $session"
								$self Register_session $session
								break
							}
						}
					}
					if { $session == "" } {
						status_log "Don't know how to handle [[$msg body] cget -euf_guid]"
						catch {$msg destroy}
						return ""
					}
					catch {$msg destroy}
				} elseif { [[$msg body] info type] == "::p2p::SLPSessionRequestBody" } {
					status_log "Unknown session"
					catch {$msg destroy}
					return ""
				} else {
					status_log "[$msg info type] : What is this type?"
					catch {$msg destroy}
					return ""
				}
				catch {$msg destroy}
			}
			$session On_blob_received $blob

		}

		method On_blob_sent {event blob} {

			set session [$self Blob_to_session $blob]
			if { $session == "" } {
				status_log "No session?!?!?!?! Something went VERY wrong" white
				return ""
			}
			$session On_blob_sent $blob

		}

		#method Find_contact { account} {}

		method Blob_to_session { blob} {

			set sid [$blob cget -session_id]
			if { $sid == 0 } {
				set slp_data [$blob read_data]
				set message [SLPMessage build $slp_data]
				$message configure -application_id [$blob cget -application_id]
				set sid [[$message body] cget -session_id]
				if { $sid == 0 || $sid == "" } {
					set cid [$message cget -call_id]
					catch {$message destroy}
					return [$self Search_session_by_call $cid]
				}
				catch {$message destroy}
			}

			return [$self Get_session $sid]

		}

	}

}